Using a Set data structure in React’s state

Posted by Ramesh Singh | Updated on

Using a Set data structure in React’s state. Since react will identify state changes only if the state property was replaced, and not mutated (shallow compare), you’ll have to create a new Set from the old one, and apply the changes to it.

Here is an example which you can use it in your class:


If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.

Related Questions & Answers