REACT Adding a new item to state

Adding a recipe works but it doesn’t stay in state. It get’s removed/replaced immediately.

I’ll be honest. I haven’t got a clue what is going on.

saveNewRecipe happens on line 62.

The saveNewRecipe function executes when the form is submitted. To prevent the form from actually submitting and refreshing the page you need to accept the event into the function and then then prevent the form from submitting. If you do that you can then go back and see the recipe you have submitted

saveNewRecipe(evt) {
    evt.preventDefault();
    console.log("adding new recipe", this.refs.recipeName.value);
    ....
2 Likes

Ok, I forgot about that “feature”.
I can work with that.