News for hackers. Stuff that matters.
Re:Ask HN: What is your favorite front end state management ... by solardev on Monday December 26, 2022 @12:32AM (#34134881)
Does it really? Hmm, I never noticed that. Will have to check for optimization opportunities then.

Does memoizing the state help?

Re:Ask HN: What is your favorite front end state management ... by mikojan on Monday December 26, 2022 @02:55PM (#34141147)
> Does it really?

It doesn't. Updating state in a component triggers the re-rendering of all its children. This is what they are referring to. You can stop that propagating effect as usual by wrapping direct descendants in React.memo().

Be aware, that an anonymous list of components will show up as "re-rendering" in the browser tools. You can verify that this is not(!) the case by looking at the profiler instead.

Additionally, if you cannot tolerate even just one component re-rendering, you can simply use React.useSynExternalStore() instead of Context.