News for hackers. Stuff that matters.
Re:Ask HN: What is your favorite front end state management ... by acemarke on Wednesday December 28, 2022 @12:26PM (#34163344)
The usual misunderstandings about context are:

- Thinking that if you change a field in the context value only components that read that field will re-render

- Thinking that _only_ the components that consume the context will re-render, not realizing that normal recursive rendering behavior resumes from there

- Not realizing that updating a context requires a `setState` call in the parent that renders the `<MyContext.Provider>`, and you can easily end up in a situation where the _entire_ component tree renders just because of default recursive rendering

Can you point to some examples of the "useless nesting" and "weird constructs" you're referring to? I'm curious to see what's happening, and if there's any docs improvements we can add to help provide guidance.

Re:Ask HN: What is your favorite front end state management ... by mikojan on Wednesday December 28, 2022 @12:53PM (#34163691)
These "misunderstandings about context" are not specific to context. React developers will have to learn about them whether they are using context or not.

> Can you point to some examples of the "useless nesting" and "weird constructs" you're referring to?

Example: Create a slice with a list of items as initial state and truncate it in a reducer.