News for hackers. Stuff that matters.
Re:How I write React after 8 years by ricardobeat on Wednesday July 27, 2022 @10:13PM (#32259713)
> Most rendering is outside the scope of state management and it doesn't matter whether you use providers or redux to manage it.

It does matter - a Context at the top of your app will trigger a full re-render on every change. Redux and other state management solutions specifically avoid using Context, and the new React 18 useSyncExternalStore hook was added for this very reason.

Re:How I write React after 8 years by nkozyra on Wednesday July 27, 2022 @11:02PM (#32260038)
As I understand it, only components that read from context render when state changes. If you want/need more granular control, you have Memo at your fingertips.

Further, the entire point of global state is you only put the stuff in there that might actually require child components get re rendered. If you're shoving everything into global state or using context when you don't need it you're doing a lot of things wrong and it's likely you'd abuse redux as well.

Re:How I write React after 8 years by schwartzworld on Thursday July 28, 2022 @12:24AM (#32260470)
People use context as a global data store which is fine if you limit global data to "things that a lot of components need to read, but very few get to write to" which is what it should be. Dark mode preferences are the canonical example.

Global state is the road to insanity in ant react app. Prefer props in all cases.