4 ms·
A common issue with "createSlice" even with seasoned developers is they're introducing useless nesting and weird imperative-functional constructs because they f
by mikojan 4y ago
A common issue with "createSlice" even with seasoned developers is they're introducing useless nesting and weird imperative-functional constructs because they fundamentally do not understand how "immer" works.
I've read your blog post, and I might be missing something, but you do not seem to be highlighting any re-rendering issues specific to context. Juniors will have to learn how React works anyway. Context or not.
- acemarke 4y agoThe 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.
- mikojan 4y agoThese "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.