Scope demo route trees with createRootAtom instead of a rootAtom prop - #90
Open
randomdevpete wants to merge 2 commits into
Open
Scope demo route trees with createRootAtom instead of a rootAtom prop#90randomdevpete wants to merge 2 commits into
randomdevpete wants to merge 2 commits into
Conversation
…om, dropping the rootAtom prop Both demos declare their route atoms as plain module-level values under a basePath-scoped root, so no factory, prop or memoisation stands between the reader and the atom chain. Ticket: 679
randomdevpete
force-pushed
the
task-679-investigate-per-demo-scoped-store-context
branch
from
August 19, 2026 00:41
a79fcfc to
8097ade
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Finding
Investigated scoping a demo's
locationAtomto a path prefix via a jotai store context, so demos could declare route atoms as plain static values instead of arootAtomprop +createXRoutes(root)factory. Not feasible with a store context, for two independent reasons (written up inpackages/jarl-atoms/DESIGN-NOTES.md):<Provider store={createStore()}>doesn't inherit from its parent — the subtree gets its ownatomWithLocation, which only refreshes onpopstate. In-subtree navigation callshistory.pushState, which fires nopopstate, so the outer store goes stale: the URL changes but every route atom outside the subtree still matches the old location.locationAtomrequires jotai 2.20's private, revision-numberedINTERNAL_buildStoreRev3API (whatjotai-scopeis built on) — the publicunstable_deriveroute is gone in this version. Not something a router should depend on.createRootAtom({ basePath })already gets the useful half of the idea in one store: route atoms below it are static module-level values, and the prefix is named once, on the root, wherereverse()can prepend it again.Change
DataGridAppandBlogRoutingAppnow callcreateRootAtom({ basePath: "/demos/..." })at module scope and declare their route atoms as plain static values — no morerootAtomprop, nocreateXRoutesfactory, no per-instanceuseMemo.Changelogwas the one other place still on the old prop-passing pattern (same shape, one param route under a static mount). Migrated it too, since it's the same small change and leaves no straggler.routes.tscorrected to describe the new mounting scheme.packages/jarl-atoms/DESIGN-NOTES.md— the project's existing home for recording rejected designs (predates this diff, already held similar entries from the v2 atoms core work) — gets a new section for this investigation.Style-guide exceptions
None.