DEV Community

loading...

Discussion on: Don't over useState

Collapse
tkdodo profile image
Dominik D Author

categories is created new in every render cycle by computeCategories. After that, we don’t update it at all. Every time data changes, React will re-render and thus call computeCategories again - giving us a new Array of categories.

Collapse
varuns924 profile image
Varun S

Oh I didn't know React rerenders the entire component for a state change. Thanks for the explanation!