@real-router/react 0.27.2 → 0.27.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/dist/cjs/{Link-CyDwbrFA.js → Link-D4K4T0Ef.js} +2 -2
  2. package/dist/cjs/{Link-CyDwbrFA.js.map → Link-D4K4T0Ef.js.map} +1 -1
  3. package/dist/cjs/{RouterProvider-CPsCmrRw.js → RouterProvider-CAaKExt_.js} +2 -2
  4. package/dist/cjs/RouterProvider-CAaKExt_.js.map +1 -0
  5. package/dist/cjs/index.js +1 -1
  6. package/dist/cjs/ink.js +1 -1
  7. package/dist/cjs/legacy.js +1 -1
  8. package/dist/esm/{Link-uERoM4yk.mjs → Link-PQIMnFd0.mjs} +2 -2
  9. package/dist/esm/{Link-uERoM4yk.mjs.map → Link-PQIMnFd0.mjs.map} +1 -1
  10. package/dist/esm/{RouterProvider-DgHypQTJ.mjs → RouterProvider-DhZoi6au.mjs} +2 -2
  11. package/dist/esm/RouterProvider-DhZoi6au.mjs.map +1 -0
  12. package/dist/esm/index.mjs +1 -1
  13. package/dist/esm/ink.mjs +1 -1
  14. package/dist/esm/legacy.mjs +1 -1
  15. package/package.json +6 -7
  16. package/dist/cjs/RouterProvider-CPsCmrRw.js.map +0 -1
  17. package/dist/esm/RouterProvider-DgHypQTJ.mjs.map +0 -1
  18. package/src/RouterProvider.tsx +0 -148
  19. package/src/components/Await.tsx +0 -46
  20. package/src/components/ClientOnly.tsx +0 -25
  21. package/src/components/HttpStatusCode.tsx +0 -66
  22. package/src/components/HttpStatusProvider.tsx +0 -26
  23. package/src/components/InkLink.tsx +0 -134
  24. package/src/components/InkRouterProvider.tsx +0 -9
  25. package/src/components/Link.tsx +0 -117
  26. package/src/components/RouterErrorBoundary.tsx +0 -69
  27. package/src/components/ServerOnly.tsx +0 -26
  28. package/src/components/Streamed.tsx +0 -30
  29. package/src/components/modern/RouteView/RouteView.tsx +0 -69
  30. package/src/components/modern/RouteView/components.tsx +0 -19
  31. package/src/components/modern/RouteView/helpers.tsx +0 -231
  32. package/src/components/modern/RouteView/index.ts +0 -8
  33. package/src/components/modern/RouteView/types.ts +0 -38
  34. package/src/constants.ts +0 -10
  35. package/src/context.ts +0 -14
  36. package/src/hooks/useDeferred.tsx +0 -34
  37. package/src/hooks/useIsActiveRoute.tsx +0 -47
  38. package/src/hooks/useNavigator.tsx +0 -15
  39. package/src/hooks/useRoute.tsx +0 -32
  40. package/src/hooks/useRouteEnter.tsx +0 -148
  41. package/src/hooks/useRouteExit.tsx +0 -159
  42. package/src/hooks/useRouteNode.tsx +0 -37
  43. package/src/hooks/useRouteUtils.tsx +0 -35
  44. package/src/hooks/useRouter.tsx +0 -15
  45. package/src/hooks/useRouterTransition.tsx +0 -17
  46. package/src/index.react-server.ts +0 -33
  47. package/src/index.ts +0 -61
  48. package/src/ink-types.ts +0 -25
  49. package/src/ink.ts +0 -30
  50. package/src/legacy.ssr.ts +0 -35
  51. package/src/legacy.ts +0 -35
  52. package/src/ssr.react-server.ts +0 -21
  53. package/src/ssr.ts +0 -43
  54. package/src/types.ts +0 -40
  55. package/src/utils/createHttpStatusSink.ts +0 -27
@@ -1,231 +0,0 @@
1
- import { UNKNOWN_ROUTE } from "@real-router/core";
2
- import { startsWithSegment } from "@real-router/route-utils";
3
- import { Activity, Children, Fragment, Suspense, isValidElement } from "react";
4
-
5
- import { Match, NotFound, Self } from "./components";
6
-
7
- import type { MatchProps, NotFoundProps, SelfProps } from "./types";
8
- import type { ReactElement, ReactNode } from "react";
9
-
10
- const MARKER_TYPES: ReadonlySet<unknown> = new Set([Match, Self, NotFound]);
11
-
12
- interface FallbackSlots {
13
- selfChildren: ReactNode;
14
- selfFallback: ReactNode | undefined;
15
- selfFound: boolean;
16
- notFoundChildren: ReactNode;
17
- }
18
-
19
- // Fixed keys used by appendFallback to distinguish the Self / NotFound
20
- // render slots from user-supplied <Match> children. Match render slots key
21
- // off `fullSegmentName` instead — these two are the only synthetic keys.
22
- const SELF_KEY = "__route-view-self__";
23
- const NOT_FOUND_KEY = "__route-view-not-found__";
24
-
25
- function isSegmentMatch(
26
- routeName: string,
27
- fullSegmentName: string,
28
- exact: boolean,
29
- ): boolean {
30
- if (fullSegmentName === "") {
31
- return false;
32
- }
33
-
34
- if (exact) {
35
- return routeName === fullSegmentName;
36
- }
37
-
38
- return startsWithSegment(routeName, fullSegmentName);
39
- }
40
-
41
- export function collectElements(
42
- children: ReactNode,
43
- result: ReactElement[],
44
- ): void {
45
- // Recurses into Fragment-like wrappers (anything that isn't Match / Self /
46
- // NotFound) to flatten the slot tree. No explicit depth guard: typical
47
- // RouteView shape is `<RouteView><Match/>...<NotFound/></RouteView>` —
48
- // depth ≤ 3 in real apps. A pathological hand-written tree of N Fragments
49
- // recurses N times; the call stack, not this function, is the bound.
50
- //
51
- // `Children.forEach` iterates without `Children.toArray`'s array allocation
52
- // and per-child clone-with-synthetic-key step. We don't read child.key here
53
- // (Match/Self/NotFound carry their own segment-derived keys further down),
54
- // so the cheaper iterator is functionally equivalent.
55
- // eslint-disable-next-line @eslint-react/no-children-for-each -- intentional: collectElements is a render-hot pipeline; toArray's array+key clone is wasteful here
56
- Children.forEach(children, (child) => {
57
- if (!isValidElement(child)) {
58
- return;
59
- }
60
-
61
- if (MARKER_TYPES.has(child.type)) {
62
- result.push(child);
63
- } else {
64
- collectElements(
65
- (child.props as { readonly children: ReactNode }).children,
66
- result,
67
- );
68
- }
69
- });
70
- }
71
-
72
- function renderSlotElement(
73
- slotChildren: ReactNode,
74
- key: string,
75
- keepAlive: boolean,
76
- mode: "visible" | "hidden",
77
- fallback?: ReactNode,
78
- ): ReactElement {
79
- const content =
80
- fallback === undefined ? (
81
- slotChildren
82
- ) : (
83
- <Suspense fallback={fallback}>{slotChildren}</Suspense>
84
- );
85
-
86
- if (keepAlive) {
87
- return (
88
- <Activity mode={mode} key={key}>
89
- {content}
90
- </Activity>
91
- );
92
- }
93
-
94
- return <Fragment key={key}>{content}</Fragment>;
95
- }
96
-
97
- function recordFallback(child: ReactElement, slots: FallbackSlots): boolean {
98
- if (child.type === NotFound) {
99
- slots.notFoundChildren = (child.props as NotFoundProps).children;
100
-
101
- return true;
102
- }
103
-
104
- if (child.type === Self) {
105
- // First-wins: subsequent <Self> elements are ignored, mirroring NotFound.
106
- if (!slots.selfFound) {
107
- slots.selfChildren = (child.props as SelfProps).children;
108
- slots.selfFallback = (child.props as SelfProps).fallback;
109
- slots.selfFound = true;
110
- }
111
-
112
- return true;
113
- }
114
-
115
- return false;
116
- }
117
-
118
- function processMatch(
119
- child: ReactElement,
120
- routeName: string,
121
- nodeName: string,
122
- hasBeenActivated: Set<string>,
123
- alreadyActive: boolean,
124
- ): { rendered: ReactElement | null; matched: boolean } {
125
- const matchProps = child.props as MatchProps;
126
- const { segment, exact = false, keepAlive = false, fallback } = matchProps;
127
- const fullSegmentName = nodeName ? `${nodeName}.${segment}` : segment;
128
- const isActive =
129
- !alreadyActive && isSegmentMatch(routeName, fullSegmentName, exact);
130
-
131
- if (isActive) {
132
- hasBeenActivated.add(fullSegmentName);
133
-
134
- return {
135
- rendered: renderSlotElement(
136
- matchProps.children,
137
- fullSegmentName,
138
- keepAlive,
139
- "visible",
140
- fallback,
141
- ),
142
- matched: true,
143
- };
144
- }
145
-
146
- if (keepAlive && hasBeenActivated.has(fullSegmentName)) {
147
- return {
148
- rendered: renderSlotElement(
149
- matchProps.children,
150
- fullSegmentName,
151
- keepAlive,
152
- "hidden",
153
- fallback,
154
- ),
155
- matched: false,
156
- };
157
- }
158
-
159
- return { rendered: null, matched: false };
160
- }
161
-
162
- function appendFallback(
163
- rendered: ReactElement[],
164
- routeName: string,
165
- nodeName: string,
166
- slots: FallbackSlots,
167
- ): void {
168
- if (slots.selfFound && routeName === nodeName) {
169
- rendered.push(
170
- renderSlotElement(
171
- slots.selfChildren,
172
- SELF_KEY,
173
- false,
174
- "visible",
175
- slots.selfFallback,
176
- ),
177
- );
178
-
179
- return;
180
- }
181
-
182
- if (routeName === UNKNOWN_ROUTE && slots.notFoundChildren !== null) {
183
- rendered.push(
184
- <Fragment key={NOT_FOUND_KEY}>{slots.notFoundChildren}</Fragment>,
185
- );
186
- }
187
- }
188
-
189
- export function buildRenderList(
190
- elements: ReactElement[],
191
- routeName: string,
192
- nodeName: string,
193
- hasBeenActivated: Set<string>,
194
- ): { rendered: ReactElement[]; activeMatchFound: boolean } {
195
- const slots: FallbackSlots = {
196
- selfChildren: null,
197
- selfFallback: undefined,
198
- selfFound: false,
199
- notFoundChildren: null,
200
- };
201
- let activeMatchFound = false;
202
- const rendered: ReactElement[] = [];
203
-
204
- for (const child of elements) {
205
- if (recordFallback(child, slots)) {
206
- continue;
207
- }
208
-
209
- const result = processMatch(
210
- child,
211
- routeName,
212
- nodeName,
213
- hasBeenActivated,
214
- activeMatchFound,
215
- );
216
-
217
- if (result.matched) {
218
- activeMatchFound = true;
219
- }
220
-
221
- if (result.rendered !== null) {
222
- rendered.push(result.rendered);
223
- }
224
- }
225
-
226
- if (!activeMatchFound) {
227
- appendFallback(rendered, routeName, nodeName, slots);
228
- }
229
-
230
- return { rendered, activeMatchFound };
231
- }
@@ -1,8 +0,0 @@
1
- export { RouteView } from "./RouteView";
2
-
3
- export type {
4
- RouteViewProps,
5
- RouteViewMatchProps,
6
- RouteViewSelfProps,
7
- RouteViewNotFoundProps,
8
- } from "./RouteView";
@@ -1,38 +0,0 @@
1
- import type { ReactNode } from "react";
2
-
3
- export interface RouteViewProps {
4
- /** Route tree node name to subscribe to. "" for root. */
5
- readonly nodeName: string;
6
- /** <RouteView.Match>, <RouteView.Self>, and <RouteView.NotFound> elements. */
7
- readonly children: ReactNode;
8
- }
9
-
10
- export interface MatchProps {
11
- /** Route segment to match against. */
12
- readonly segment: string;
13
- /** Exact match only (no descendants). Defaults to false. */
14
- readonly exact?: boolean;
15
- /** Preserve component state when deactivated (React Activity). Defaults to false. */
16
- readonly keepAlive?: boolean;
17
- /** Fallback content to show while children are suspended. */
18
- readonly fallback?: ReactNode;
19
- /** Content to render when matched. */
20
- readonly children: ReactNode;
21
- }
22
-
23
- export interface SelfProps {
24
- /**
25
- * Fallback content to show while children are suspended.
26
- *
27
- * Symmetric with `<RouteView.Match fallback>` — wraps children in
28
- * `<Suspense>` when defined.
29
- */
30
- readonly fallback?: ReactNode;
31
- /** Content to render when the active route name equals the parent RouteView's nodeName. */
32
- readonly children: ReactNode;
33
- }
34
-
35
- export interface NotFoundProps {
36
- /** Content to render on UNKNOWN_ROUTE. */
37
- readonly children: ReactNode;
38
- }
package/src/constants.ts DELETED
@@ -1,10 +0,0 @@
1
- export const EMPTY_PARAMS = Object.freeze({});
2
-
3
- export const EMPTY_OPTIONS = Object.freeze({});
4
-
5
- // Singleton forever-pending promise — module-scope so `useDeferred(unknownKey)`
6
- // returns a stable reference across calls (Suspense boundary doesn't retry).
7
- export const NEVER_PROMISE = new Promise<never>(() => {
8
- // Intentionally never resolves — surfaces a forever-pending Suspense boundary
9
- // when a key is requested that the loader never declared.
10
- });
package/src/context.ts DELETED
@@ -1,14 +0,0 @@
1
- import { createContext } from "react";
2
-
3
- import type { RouteContext as RouteContextType } from "./types";
4
- import type { Router, Navigator } from "@real-router/core";
5
-
6
- // All three contexts use the `<T | null>` shape with a `null` default. Hooks
7
- // (useRouter / useRoute / useNavigator) treat a `null` read as
8
- // "RouterProvider missing" and throw — this surfaces wiring mistakes loudly
9
- // instead of letting consumers chase an undefined router instance.
10
- export const RouteContext = createContext<RouteContextType | null>(null);
11
-
12
- export const RouterContext = createContext<Router | null>(null);
13
-
14
- export const NavigatorContext = createContext<Navigator | null>(null);
@@ -1,34 +0,0 @@
1
- import { NEVER_PROMISE } from "../constants";
2
- import { useRoute } from "./useRoute";
3
-
4
- interface DeferredContext {
5
- ssrDataDeferred?: Record<string, Promise<unknown>>;
6
- }
7
-
8
- /**
9
- * Read a deferred promise published by `defer({ deferred: { <key>: Promise } })`
10
- * inside an SSR data loader.
11
- *
12
- * - **Server render**: returns the actual loader-returned promise. Combine
13
- * with `<Suspense>` + `use(promise)` for native streaming via React 19's
14
- * `renderToReadableStream`.
15
- * - **Post-hydration**: returns a registry-backed promise; the inline
16
- * `<script>__rrDefer__("key", json)</script>` tags emitted by the server
17
- * stream resolve it. `use()` returns synchronously once the registry
18
- * settles.
19
- * - **Unknown key**: returns a never-resolving promise — Suspense boundary
20
- * stays in fallback. This surfaces consumer/loader key drift as a visible
21
- * loading state instead of a silent runtime error.
22
- *
23
- * The hook subscribes to `RouteContext`, so it re-runs on every navigation.
24
- * Promise reference identity is stable across renders within the same
25
- * navigation — `use()` will not re-suspend on rerenders.
26
- */
27
- export function useDeferred<T = unknown>(key: string): Promise<T> {
28
- const { route } = useRoute();
29
- const context = route.context as DeferredContext;
30
- const deferred = context.ssrDataDeferred;
31
- const promise = deferred?.[key];
32
-
33
- return (promise ?? NEVER_PROMISE) as Promise<T>;
34
- }
@@ -1,47 +0,0 @@
1
- import { createActiveRouteSource } from "@real-router/sources";
2
- import { useMemo, useSyncExternalStore } from "react";
3
-
4
- import { useRouter } from "./useRouter";
5
-
6
- import type { Params } from "@real-router/core";
7
-
8
- export function useIsActiveRoute(
9
- routeName: string,
10
- params?: Params,
11
- strict = false,
12
- ignoreQueryParams = true,
13
- hash?: string,
14
- ): boolean {
15
- const router = useRouter();
16
-
17
- // createActiveRouteSource is per-router + canonical-args cached in
18
- // @real-router/sources, so passing params by reference is safe — equivalent
19
- // param shapes hit the same cache entry regardless of key order. The
20
- // `hash` argument (#532) is part of the cache key when defined: a Link
21
- // pointing to `/settings#account` shares its source only with other
22
- // consumers using the same routeName + params + hash.
23
- //
24
- // The useMemo wrap skips `canonicalJson(params)` + cache lookup on every
25
- // render when all primitive deps and the `params` reference are stable —
26
- // the common case once memo()+shallowEqual has bailed out further up
27
- // (or when the parent re-renders for a non-Link reason). For inline
28
- // `params={{id:1}}` the dep changes per render and the lookup still
29
- // runs, but that path was already the slow path before this memo.
30
- // exactOptionalPropertyTypes forbids `{ hash: undefined }` literally, so
31
- // we conditionally spread the key only when the caller passed a value.
32
- const store = useMemo(
33
- () =>
34
- createActiveRouteSource(router, routeName, params, {
35
- strict,
36
- ignoreQueryParams,
37
- ...(hash !== undefined && { hash }),
38
- }),
39
- [router, routeName, params, strict, ignoreQueryParams, hash],
40
- );
41
-
42
- return useSyncExternalStore(
43
- store.subscribe,
44
- store.getSnapshot,
45
- store.getSnapshot,
46
- );
47
- }
@@ -1,15 +0,0 @@
1
- import { useContext } from "react";
2
-
3
- import { NavigatorContext } from "../context";
4
-
5
- import type { Navigator } from "@real-router/core";
6
-
7
- export const useNavigator = (): Navigator => {
8
- const navigator = useContext(NavigatorContext);
9
-
10
- if (!navigator) {
11
- throw new Error("useNavigator must be used within a RouterProvider");
12
- }
13
-
14
- return navigator;
15
- };
@@ -1,32 +0,0 @@
1
- import { useContext } from "react";
2
-
3
- import { RouteContext } from "../context";
4
-
5
- import type { RouteContext as RouteContextType } from "../types";
6
- import type { Params, State } from "@real-router/core";
7
-
8
- /**
9
- * Return shape of `useRoute<P>()` — the context with `route` narrowed to
10
- * `State<P>` (non-nullable). Promoting the intersection to a named alias
11
- * keeps the function signature and the cast site in sync.
12
- */
13
- type RouteHookResult<P extends Params = Params> = Omit<
14
- RouteContextType<P>,
15
- "route"
16
- > & { route: State<P> };
17
-
18
- export const useRoute = <P extends Params = Params>(): RouteHookResult<P> => {
19
- const routeContext = useContext(RouteContext);
20
-
21
- if (!routeContext) {
22
- throw new Error("useRoute must be used within a RouterProvider");
23
- }
24
-
25
- if (!routeContext.route) {
26
- throw new Error(
27
- "useRoute called with no active route. Did you forget to await router.start() before rendering, or is the router stopped/disposed?",
28
- );
29
- }
30
-
31
- return routeContext as RouteHookResult<P>;
32
- };
@@ -1,148 +0,0 @@
1
- import { useEffect, useLayoutEffect, useRef } from "react";
2
-
3
- import { useRoute } from "./useRoute";
4
-
5
- import type { State } from "@real-router/core";
6
-
7
- export interface RouteEnterContext {
8
- /** The route that was just activated. */
9
- route: State;
10
- /** The route that was active immediately before this navigation. */
11
- previousRoute: State;
12
- }
13
-
14
- export type RouteEnterHandler = (context: RouteEnterContext) => void;
15
-
16
- export interface UseRouteEnterOptions {
17
- /**
18
- * Skip the handler when `route.name === previousRoute.name`
19
- * (sort/filter/query-only navigations on the same route). Default:
20
- * `true`. Symmetric with `useRouteExit`'s same-name option.
21
- */
22
- skipSameRoute?: boolean;
23
- }
24
-
25
- /**
26
- * Fire `handler` once when the component mounts as a result of a
27
- * navigation. Mirror of `useRouteExit` for the entry side.
28
- *
29
- * What this hook covers that ad-hoc `useEffect` + `useRoute()` doesn't:
30
- *
31
- * - **Skip-initial**: handler is skipped when there is no
32
- * `previousRoute` (i.e. first-load mount). Most consumers want to
33
- * fire side effects only on real navigations, not on hydration.
34
- * - **Same-route skip** (default): handler is skipped when
35
- * `route.name === previousRoute.name`. Sort/filter/query-only
36
- * navigations re-run the effect (because `route` reference changes
37
- * in `useRoute`'s snapshot), but they are not "entries" in the
38
- * animation / analytics sense — the component instance has stayed
39
- * mounted throughout. Opt out with `skipSameRoute: false` when
40
- * the handler legitimately needs to fire on every navigation
41
- * (e.g. analytics tracking each query-param flip).
42
- * - **StrictMode double-mount immunity**: in dev, React's StrictMode
43
- * runs every effect twice to surface bugs. Without a guard,
44
- * analytics fire twice, animations restart, focus jumps. The hook
45
- * tracks the last-handled `route` reference and short-circuits the
46
- * second pass.
47
- * - **Latest-handler ref**: the handler can change identity on every
48
- * render without re-running the effect — the registered wrapper
49
- * dispatches to whatever `handlerRef.current` points to.
50
- * - **Mount-time `route` / `previousRoute` snapshot**: the handler
51
- * receives the values that were live at the moment of mount, not
52
- * the latest ones (which may have moved on if the user navigated
53
- * again before the effect drained).
54
- *
55
- * Race-safety: `useRoute()` is wired through `useSyncExternalStore` from
56
- * `@real-router/sources`, so by the time the new component's effect
57
- * runs, the snapshot is the post-commit one. This is the reason we can
58
- * read mount-time context from `useRoute()` instead of subscribing to
59
- * `router.subscribe` directly (which fires before React schedules a
60
- * re-render — the well-known race in distributed components).
61
- *
62
- * @example Direction-aware entry animation
63
- * ```tsx
64
- * useRouteEnter(({ route }) => {
65
- * const direction = route.context.browser?.direction;
66
- * ref.current?.classList.add(
67
- * direction === "back" ? "slide-from-left" : "slide-from-right",
68
- * );
69
- * });
70
- * ```
71
- *
72
- * @example Source-aware focus management
73
- * ```tsx
74
- * useRouteEnter(({ route }) => {
75
- * if (route.context.browser?.source === "navigate") {
76
- * headingRef.current?.focus();
77
- * }
78
- * });
79
- * ```
80
- *
81
- * @example Analytics page-enter event (skip-initial built-in)
82
- * ```tsx
83
- * useRouteEnter(({ route, previousRoute }) => {
84
- * analytics.track("page_enter", {
85
- * route: route.name,
86
- * from: previousRoute.name,
87
- * });
88
- * });
89
- * ```
90
- *
91
- * @example Reading rich transition metadata via `route.transition`
92
- * ```tsx
93
- * useRouteEnter(({ route }) => {
94
- * // route.transition: TransitionMeta — populated by core for every state
95
- * if (route.transition.redirected) {
96
- * showToast(`Redirected from ${route.transition.from}`);
97
- * }
98
- * if (route.transition.segments.activated.includes("products")) {
99
- * // products subtree just became active (could be products or
100
- * // products.detail). Useful for subtree-scoped side effects.
101
- * }
102
- * });
103
- * ```
104
- */
105
- export function useRouteEnter(
106
- handler: RouteEnterHandler,
107
- options?: UseRouteEnterOptions,
108
- ): void {
109
- const { route, previousRoute } = useRoute();
110
- const handlerRef = useRef(handler);
111
- const lastHandledRouteRef = useRef<State | null>(null);
112
- const skipSameRoute = options?.skipSameRoute ?? true;
113
-
114
- // Keep the latest handler reference accessible without re-running
115
- // the effect. useLayoutEffect (synchronous, post-render, pre-paint)
116
- // updates the ref before the effect can read it.
117
- useLayoutEffect(() => {
118
- handlerRef.current = handler;
119
- });
120
-
121
- useEffect(() => {
122
- // Early-exit guards, top-down:
123
- //
124
- // - **Skip-initial**: `state.transition.from` is undefined only
125
- // for the very first state committed by `router.start()`.
126
- // - **Skip-same-route**: query-only navigations have
127
- // `transition.from === route.name`. Opt-out via
128
- // `skipSameRoute: false`.
129
- // - **StrictMode dedupe**: same `route` ref between effect
130
- // cleanup + re-run in dev's strict pass. Not testable from
131
- // vitest (`NODE_ENV === "test"` disables React's strict-mode
132
- // double-run), so v8-ignored.
133
- if (!route.transition.from) {
134
- return;
135
- }
136
- if (skipSameRoute && route.transition.from === route.name) {
137
- return;
138
- }
139
- /* v8 ignore start */
140
- if (lastHandledRouteRef.current === route || !previousRoute) {
141
- return;
142
- }
143
- /* v8 ignore stop */
144
-
145
- lastHandledRouteRef.current = route;
146
- handlerRef.current({ route, previousRoute });
147
- }, [route, previousRoute, skipSameRoute]);
148
- }