I have a question about how to refactor overlay components in a very big WebApp with Jotai. I have two options in mind and would like your opinion on them.
The goal is to prevent rerendering of overlay Y if overlay X changes.
Option 1: Create atoms in overlay file. Consume atoms directly in the overlay components
Example Sandbox
Benefits: Less Code, What belongs together lives together
Disadvantages: Overlays cannot be used outside of Jotai because they dont receive props
Option 2: Create atoms in overlay file. Consume atoms in a wrapper component which passes the state to the overlay as props
Example Sandbox
Benefits: Reusability, overlays can be used independently too
Disadvantages: More code
What do you think, which option is better? And why do you think so?
Thanks alot