@native-router/react 1.6.0 → 1.6.1
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.
- package/README.md +9 -0
- package/dist/types/types.d.ts +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -141,6 +141,15 @@ The navigation semantics stay owned by the link: `href` is always the computed t
|
|
|
141
141
|
|
|
142
142
|
`PrefetchLink`'s strategies keep working through the `as` component; the `viewport` strategy observes the DOM node the component forwards its ref to, so a component that never forwards the ref down to a DOM element simply never triggers a viewport prefetch.
|
|
143
143
|
|
|
144
|
+
## Why `useData` is typed manually
|
|
145
|
+
|
|
146
|
+
`useData<T>()` annotations have no compile-time link to the route's `data` loader — the annotation *is* the contract. That is deliberate. Two closure schemes were evaluated (2026-08) and rejected:
|
|
147
|
+
|
|
148
|
+
- **A from-argument** (`useData('/articles/:slug')`, indexing a route-table map by path literal — TanStack's `useLoaderData({from})` shape). Rejected: it makes every view aware of the path it happens to be mounted under. Matching data to a view is the route configuration's job; a view should know what it renders, not where it is mounted.
|
|
149
|
+
- **A data-props protocol** — constrain `component` to `ComponentType<{data: D}>` and let `createRoutes` check the loader output against it at the config site. The check lands at the right layer, but deep children would then need prop drilling to reach the data.
|
|
150
|
+
|
|
151
|
+
What stays: path-agnostic views, no prop drilling, one local annotation. Revisit only if TypeScript or the library later offers a channel that couples neither paths nor props.
|
|
152
|
+
|
|
144
153
|
## Install
|
|
145
154
|
|
|
146
155
|
```bash
|
package/dist/types/types.d.ts
CHANGED
|
@@ -170,7 +170,7 @@ export type WithSearch<C, S> = Omit<C, 'search'> & {
|
|
|
170
170
|
* @group Types
|
|
171
171
|
* @category Route
|
|
172
172
|
*/
|
|
173
|
-
export type SearchRoutesOf<T> = T extends readonly
|
|
173
|
+
export type SearchRoutesOf<T> = T extends readonly unknown[] ? {
|
|
174
174
|
-readonly [K in keyof T]: SearchRoutesOf<T[K]>;
|
|
175
175
|
} : T extends Route ? T extends {
|
|
176
176
|
data?: infer Data;
|