0
Why aren’t you getting the.type action? just exits by default.
The log is saying "editing" which is the default case instead of creating a new article.
The code
handleActions(action) {
switch (action) {
case action.type === ActionTypes.CREATE_ARTICLE:
this.setState.article.id = Counter.increment();
this.setState.article.title = action.title;
this.setState.article.content = action.content;
console.log("adicionado")
break;
case action.type === ActionTypes.DELETE_ARTICLE:
console.log("deletando")
break;
default:
console.log("editando")
break;
}
}
Log print:
In the image above creates the object but the log leaves in the default "editing".
What gives
console.log(action, ActionTypes.CREATE_ARTICLE);
?– Sergio
Gives the screenshot of the print I posted on the question. This object of type CREATE_ARTICLE.
– Danilo Silva
And
console.log(ActionTypes.CREATE_ARTICLE);
?– Sergio
same thing. The bid is q instead of falling into case 1 which is the CREATE_ARTICLE is falling into the default. That’s the problem.
– Danilo Silva
@Sergio I changed the code a little and the error changed. Now it appears this:
TypeError: Cannot read property 'article' of undefined
It is on that line:this.setState.article.id = Counter.increment();
And the constructor that has this id is this: ;constructor() {
 super();
 this.article = {
 id: "",
 title: "",
 article: ""
 }
 }
– Danilo Silva