pmndrs / jotai

👻 Primitive and flexible state management for React
https://jotai.org
MIT License
18.61k stars 607 forks source link

idea1: add originator prop to atomFamily atoms #2678

Closed dmaskasky closed 3 months ago

dmaskasky commented 3 months ago

Related Bug Reports or Discussions

idea2: https://github.com/pmndrs/jotai/pull/2679

Fixes # https://github.com/jotaijs/jotai-scope/issues/50

Summary

jotai-scope is trying to support scoping atomFamily.

const fooFamily = atomFamily((id) => atom(id))
<ScopedProvider atoms={[fooFamily]}>{children}</ScopeProvider>

This PR demonstrates one approach in which the atomFamily annotates atoms created by this approach with an originator symbol set to the createAtom function.

The following pseudo code represents logic that would live in jotai-scope

const isExplicitlyScoped = atomSet.has(atom) || atomSet.has(atom[SymbolOriginator])

Check List

vercel[bot] commented 3 months ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
jotai ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 29, 2024 3:20am
codesandbox-ci[bot] commented 3 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.

github-actions[bot] commented 3 months ago

LiveCodes Preview in LiveCodes

Latest commit: 28179607e155fe0e379ddf630235ccf5eb03bd05
Last updated: Jul 29, 2024 3:19am (UTC)

Playground Link
React demo https://livecodes.io?x=id/DK7S5BLGC

See documentations for usage instructions.