re: Let's build a search bar in React! VIEW POST

TOP OF THREAD FULL DISCUSSION
re: Thanks for the article. You addItem/removeItem has a fairly unlikely race condition in it. You are reading the list from the state, modifying it,...
 

Interesting. How would you suggest preventing that issue in a project like this?

 

Use call back format for setState.

this.setState(state => {
  const list = state.list;
  /* modify list */;
  return {
    list: modifiedList
  };
});
code of conduct - report abuse