Crawleyprint / react-dialog

React hooks and components for easier using native html dialog element as modals and dropdowns
https://react-dialog.vercel.app
3 stars 1 forks source link

Memoize the main component #3

Open mario-petrovic opened 4 months ago

mario-petrovic commented 4 months ago

It would be awesome to memoize the main component, as to reduce the unnecessary rerender from the top level component.

I know this is imlicit for new react, it may not memoize implicitly if parent app is in react 18 or lower. It is worth to test it out locally.

Crawleyprint commented 4 months ago

I've taken a quick look at profiler and it looks like this isn't necessary since it only renders the dialog once and uses refs afterwards. I'll keep this issue open for now, so feel free to add your thoughts. In any case, it might be worth adding an explanation to the docs - it might be useful to memoize children components passed to dialog as they can be heavy on computation, but the dialog itself is not.