react-reverse-portal icon indicating copy to clipboard operation
react-reverse-portal copied to clipboard

Child components are re-rendered when switching their OutPortal

Open bduffany opened this issue 4 years ago • 1 comments

See this example: https://codesandbox.io/s/nifty-fire-ihho4?file=/src/index.tsx

When switching the OutPortal, the child component of the InPortal (i.e. the "expensive" component) appears to get re-rendered, although the component that is rendering the InPortal doesn't get re-rendered.

Is this a bug or is there a problem with that example?

bduffany avatar Dec 13 '20 19:12 bduffany

It does appear that if I use React.PureComponent, the component does not re-render: https://codesandbox.io/s/affectionate-bouman-y201q?file=/src/index.tsx.

However it's rendered twice initially. Is this also a bug? (EDIT: I sent #19 to fix this)

bduffany avatar Dec 13 '20 20:12 bduffany