Monday 16 July 2018

ReactJs: Why must I click my button twice to add an item to my list?

I coded a pretty basic list and add item form with ReactJs.

enter image description here

I can add an item to this list by entering a value and clicking the "Add an item" button.

Unfortunately, if I immediately want to add a 2nd item, I have to click the button twice. (It seems like if I pause for two seconds, it works just fine.)

How can I fix this so that I only have to click the button once to add the second item?

I've included my code on codesandbox.io below:

Edit x6jop5434



from ReactJs: Why must I click my button twice to add an item to my list?

No comments:

Post a Comment