I have parent with multiple children, I want to only re-render selected children, not parent component over and over.
const ParentComp = () =>
{
const [state1, setState1] = useState(0);
const [state2, setState2] = useState(0);
const [state3, setState3] = useState(0);
// ... more children if needed
// example: do something complex based on events
// and update states for desired component
return(
// ... parent stuff
<ChildComp1 state=state1/>
<ChildComp1 state=state2/>
<ChildComp1 state=state3/>
// ... parent stuff
)
}
I can wrap children in memo and it will render selected child component but it will still re-render parent.