React setState is actually somewhat asyncronous. Take a look here for an explanation.
So if you change code in your deleteRecipe method from
localStorage.setItem(localStorageKey, JSON.stringify(this.state.recipes));
to
localStorage.setItem(localStorageKey, JSON.stringify(newRecipeState));
everyhting will work fine.
1 Like
okay…ill read up…i have noticed weird behavior of setState…i had to use a setTimeout in another app because something i did right after setState was happening too fast…im a newb but the asynchronous nature of setState is why i had to do that??..i think it was a call to a method that did an ajax request…anyway thanks for the help ill try it out