Closed dmaskasky closed 2 months ago
This pull request is automatically built and testable in CodeSandbox.
To see build info of the built libraries, click here or the icon next to each commit SHA.
Quick question on the implementation: once the ScopeProvider unmounts, should all the keys that were set within that scope be automatically removed?
Quick question on the implementation: once the ScopeProvider unmounts, should all the keys that were set within that scope be automatically removed?
Yes. When the ScopeProvider unmounts, atomSet
and atomFamilySet
are no longer referenced and are available for garbage collection.
Summary
Adds support for scoping
atomFamily
instances within theScopeProvider
. This allows for better state isolation and management when usingatomFamily
, enabling scoped states to be cleanly separated and managed within specific contexts.Motivation
The ability to scope
atomFamilies
was identified as a necessary feature for more complex state management scenarios, particularly in larger applications where isolated state is crucial for maintainability and performance.Fixes https://github.com/jotaijs/jotai-scope/issues/50
Future Work
The tests for atom removal in scoped
atomFamilies
are currently marked as TODO. RefactoringatomFamily
may be required to support descoping and removing atoms.Impact
This update will primarily benefit developers who need to manage complex state scenarios involving
atomFamily
. Existing functionality remains unaffected, but users will need to ensure compatibility with the updated Jotai version.