DEV Community

Discussion on: How to make routable modals in react with react-router

Collapse
 
ausmurp profile image
Austin Murphy

I don't think you can avoid re rendering parent but you can memoize the components on parent as you attempted. It should work fine. You can:

const ContactsMemo = useMemo(() => <Contacts />, []);

<Parent>
  {ContactsMemo}
<Parent>

Enter fullscreen mode Exit fullscreen mode