DEV Community


Discussion on: Don't over useState

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.

varuns924 profile image
Varun S

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