There are multiple other ways to avoid having "the rest of the app" re-render here, including memoizing the rendered child component elements in App, wrapping the immediate child in React.memo(), and use of props.children.
I am suggesting that apart from those optimizations, we can isolate the state & re-renders to the sub-tree where it is used. And if required, we can set it from anywhere in our code.
I am trying to establish that we shouldn't be lifting the state up only because we want to update the state from another place!
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
There are multiple other ways to avoid having "the rest of the app" re-render here, including memoizing the rendered child component elements in
App
, wrapping the immediate child inReact.memo()
, and use ofprops.children
.Agreed Mark!
I am suggesting that apart from those optimizations, we can isolate the state & re-renders to the sub-tree where it is used. And if required, we can set it from anywhere in our code.
I am trying to establish that we shouldn't be lifting the state up only because we want to update the state from another place!