DEV Community

Discussion on: Memoisation in React

Collapse
 
papercoding22 profile image
Paper Coding

Thank you for sharing ! with your example above, I have some idea, instead of placing input state in App which is the parent of children , we create a stateful component for that input, like InputSelfHandling which has its own state.

But let's say we need to share the text state with another component, example a banner to show input's value, so we consider whether we can group both of them into a wrapper. By doing that, other children in App which don't need that text state, won't be re-rendered when the text changed.

So the idea is just simple as wrapping small components which use the shared state together instead of putting all state in a root parent.