diff --git a/.changeset/route-owner-create-root.md b/.changeset/route-owner-create-root.md new file mode 100644 index 00000000..37259e7d --- /dev/null +++ b/.changeset/route-owner-create-root.md @@ -0,0 +1,5 @@ +--- +"@solidjs/router": patch +--- + +The router's route-root owner now comes from `createRoot(() => getOwner())` instead of `createOwner()`. `createOwner` is leaving solid-js's public types (solid#4515, typed only through `solid-js/internal`), and this uses only public API with the same parent, hydration ids and disposal. diff --git a/src/routers/components.tsx b/src/routers/components.tsx index e36451d3..0c8d2f61 100644 --- a/src/routers/components.tsx +++ b/src/routers/components.tsx @@ -4,8 +4,8 @@ import type {Component} from "solid-js"; import type {JSX} from "@solidjs/web"; import { createMemo, - createOwner, createRoot, + getOwner, onCleanup, runWithOwner, untrack, @@ -100,7 +100,10 @@ export function Routes(props: { routerState: RouterContext; branches: () => Bran // dedicated one, created before the memo: the roots draw hydration ids from // its counter, so the ids don't depend on whether the memo first parked on // a lazy subtree (the server's render can park where the client's doesn't). - const owner = createOwner(); + // `createRoot` hands back the same kind of owner `createOwner` would, minus + // the bound `dispose` the public `createOwner` pays for (solid#4444): this + // owner is only ever disposed with the component. + const owner = createRoot(() => getOwner()!); const routeStates = createMemo((prev: RouteContext[] | undefined) => { // While a lazy subtree resolves, `matches()` is not ready and this