@molecule/app-routing-react-router 1.2.1 → 1.2.2
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 +30 -7
- package/dist/hooks.d.ts +20 -6
- package/dist/hooks.d.ts.map +1 -1
- package/dist/hooks.js +31 -11
- package/dist/hooks.js.map +1 -1
- package/dist/index.d.ts +10 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@ AUTO-GENERATED — DO NOT EDIT THIS FILE.
|
|
|
3
3
|
Generated by `mlcl sync-docs` from the package's src/index.ts JSDoc + mlcl/registry.json.
|
|
4
4
|
Edits here are overwritten on the next commit (molecule's pre-commit hook regenerates).
|
|
5
5
|
To change this document, edit the module-level JSDoc in src/index.ts.
|
|
6
|
-
Generated: 2026-11-
|
|
6
|
+
Generated: 2026-11-05T21:31:18.760Z
|
|
7
7
|
-->
|
|
8
8
|
|
|
9
9
|
# @molecule/app-routing-react-router
|
|
@@ -13,6 +13,14 @@ React Router (v7/v8) provider for `@molecule/app-routing`.
|
|
|
13
13
|
This package provides a React Router implementation of the molecule Router interface,
|
|
14
14
|
allowing you to use molecule's routing abstractions with React Router.
|
|
15
15
|
|
|
16
|
+
`useMoleculeRouter`, `useMoleculeQuery`, `useMoleculeNavigate`, and `useIsActive`
|
|
17
|
+
work inside any React Router router (BrowserRouter, HashRouter, MemoryRouter,
|
|
18
|
+
Router, or RouterProvider), from this package or React Router itself. No
|
|
19
|
+
MoleculeRouterProvider is required for these hooks. Mount MoleculeRouterProvider
|
|
20
|
+
only to bond the adapter for non-React `@molecule/app-routing` navigate()/getRouter(),
|
|
21
|
+
supply named routes, or receive onRouterReady. Hook-created adapters remain local
|
|
22
|
+
so multiple consumers cannot overwrite the global router bond.
|
|
23
|
+
|
|
16
24
|
**Paginated or filtered page? Use `useListRoute` for its URL state.** It reads
|
|
17
25
|
page, filters and selected views from the current URL; builds links that retain
|
|
18
26
|
the current path/filters; and resets page when a filter or view changes. Declare
|
|
@@ -30,6 +38,7 @@ import { Routes, Route } from 'react-router'
|
|
|
30
38
|
import { BrowserRouter, MoleculeRouterProvider } from '@molecule/app-routing-react-router'
|
|
31
39
|
|
|
32
40
|
function App() {
|
|
41
|
+
// Optional: include this provider for non-React navigation or named routes.
|
|
33
42
|
// MoleculeRouterProvider bonds the adapter automatically (calls setRouter in an
|
|
34
43
|
// effect on mount), so @molecule/app-routing's navigate()/getRouter() drive THIS
|
|
35
44
|
// real React Router — no manual setRouter wiring needed.
|
|
@@ -653,7 +662,8 @@ bonds it as the active singleton via `@molecule/app-routing`'s `setRouter`.
|
|
|
653
662
|
Bonding happens in an effect on mount (and again whenever the location/params
|
|
654
663
|
change), so `@molecule/app-routing`'s `navigate()`/`getRouter()` drive THIS real
|
|
655
664
|
React Router adapter — no manual `setRouter` wiring required. Mount it once inside
|
|
656
|
-
|
|
665
|
+
any React Router router when non-React code needs the bond, named routes are
|
|
666
|
+
configured, or `onRouterReady` is needed. The routing hooks work without this provider.
|
|
657
667
|
|
|
658
668
|
```typescript
|
|
659
669
|
function MoleculeRouterProvider(props: MoleculeRouterProviderProps): React.JSX.Element
|
|
@@ -665,7 +675,14 @@ function MoleculeRouterProvider(props: MoleculeRouterProviderProps): React.JSX.E
|
|
|
665
675
|
|
|
666
676
|
#### `useMoleculeRouter()`
|
|
667
677
|
|
|
668
|
-
Hook to get the molecule Router
|
|
678
|
+
Hook to get the molecule Router inside any React Router router, including
|
|
679
|
+
BrowserRouter, HashRouter, MemoryRouter, Router, or RouterProvider from this
|
|
680
|
+
package or React Router itself. No MoleculeRouterProvider is required.
|
|
681
|
+
|
|
682
|
+
When MoleculeRouterProvider is mounted, returns its exact router with its named
|
|
683
|
+
routes. Otherwise creates a local adapter from React Router's hooks without
|
|
684
|
+
bonding it globally. Mount MoleculeRouterProvider for the non-React
|
|
685
|
+
`@molecule/app-routing` navigate()/getRouter() bond or onRouterReady.
|
|
669
686
|
|
|
670
687
|
```typescript
|
|
671
688
|
function useMoleculeRouter(): Router
|
|
@@ -675,7 +692,9 @@ function useMoleculeRouter(): Router
|
|
|
675
692
|
|
|
676
693
|
#### `useIsActive(path, exact)`
|
|
677
694
|
|
|
678
|
-
Hook to check if a path is currently active.
|
|
695
|
+
Hook to check if a path is currently active inside any React Router router.
|
|
696
|
+
MoleculeRouterProvider is optional; mount it only for named routes, the
|
|
697
|
+
non-React navigate()/getRouter() bond, or onRouterReady.
|
|
679
698
|
|
|
680
699
|
```typescript
|
|
681
700
|
function useIsActive(path: string, exact?: boolean): boolean
|
|
@@ -688,7 +707,9 @@ function useIsActive(path: string, exact?: boolean): boolean
|
|
|
688
707
|
|
|
689
708
|
#### `useMoleculeNavigate()`
|
|
690
709
|
|
|
691
|
-
Hook to get a navigate function with molecule Router options
|
|
710
|
+
Hook to get a navigate function with molecule Router options inside any React
|
|
711
|
+
Router router. MoleculeRouterProvider is optional; mount it only for named
|
|
712
|
+
routes, the non-React navigate()/getRouter() bond, or onRouterReady.
|
|
692
713
|
|
|
693
714
|
```typescript
|
|
694
715
|
function useMoleculeNavigate(): Router['navigate']
|
|
@@ -698,7 +719,9 @@ function useMoleculeNavigate(): Router['navigate']
|
|
|
698
719
|
|
|
699
720
|
#### `useMoleculeQuery()`
|
|
700
721
|
|
|
701
|
-
Hook to get current query params as an object.
|
|
722
|
+
Hook to get current query params as an object inside any React Router router.
|
|
723
|
+
MoleculeRouterProvider is optional; mount it only for named routes, the
|
|
724
|
+
non-React navigate()/getRouter() bond, or onRouterReady.
|
|
702
725
|
|
|
703
726
|
```typescript
|
|
704
727
|
function useMoleculeQuery(): QueryParams
|
|
@@ -986,7 +1009,7 @@ Peer dependencies:
|
|
|
986
1009
|
- **Do NOT wire the exported `provider` const** in a React Router app — it is a
|
|
987
1010
|
no-hooks fallback (empty params, `window.location.href` navigation). Use
|
|
988
1011
|
`MoleculeRouterProvider` (or `createReactRouter` with hook values) instead.
|
|
989
|
-
- The provider must live INSIDE
|
|
1012
|
+
- The provider must live INSIDE a React Router router (it calls React Router hooks).
|
|
990
1013
|
- **Import router components from this bond, never directly from React Router.**
|
|
991
1014
|
Its wrappers turn transitions off, so a navigation renders the new route in the
|
|
992
1015
|
same commit as the URL change. Import non-router APIs (`Routes`, `Route`, `Link`,
|
package/dist/hooks.d.ts
CHANGED
|
@@ -29,7 +29,8 @@ export interface MoleculeRouterProviderProps {
|
|
|
29
29
|
* Bonding happens in an effect on mount (and again whenever the location/params
|
|
30
30
|
* change), so `@molecule/app-routing`'s `navigate()`/`getRouter()` drive THIS real
|
|
31
31
|
* React Router adapter — no manual `setRouter` wiring required. Mount it once inside
|
|
32
|
-
*
|
|
32
|
+
* any React Router router when non-React code needs the bond, named routes are
|
|
33
|
+
* configured, or `onRouterReady` is needed. The routing hooks work without this provider.
|
|
33
34
|
*
|
|
34
35
|
* @param props - The provider props (see {@link MoleculeRouterProviderProps}):
|
|
35
36
|
* `children` (rendered inside the router context), `routes` (optional named-route
|
|
@@ -59,10 +60,17 @@ export interface MoleculeRouterProviderProps {
|
|
|
59
60
|
*/
|
|
60
61
|
export declare function MoleculeRouterProvider(props: MoleculeRouterProviderProps): React.JSX.Element;
|
|
61
62
|
/**
|
|
62
|
-
* Hook to get the molecule Router
|
|
63
|
+
* Hook to get the molecule Router inside any React Router router, including
|
|
64
|
+
* BrowserRouter, HashRouter, MemoryRouter, Router, or RouterProvider from this
|
|
65
|
+
* package or React Router itself. No MoleculeRouterProvider is required.
|
|
66
|
+
*
|
|
67
|
+
* When MoleculeRouterProvider is mounted, returns its exact router with its named
|
|
68
|
+
* routes. Otherwise creates a local adapter from React Router's hooks without
|
|
69
|
+
* bonding it globally. Mount MoleculeRouterProvider for the non-React
|
|
70
|
+
* `@molecule/app-routing` navigate()/getRouter() bond or onRouterReady.
|
|
63
71
|
*
|
|
64
72
|
* @returns The molecule Router instance
|
|
65
|
-
* @throws {Error} If used outside
|
|
73
|
+
* @throws {Error} If used outside a React Router router; mount a router component.
|
|
66
74
|
*
|
|
67
75
|
* @example
|
|
68
76
|
* ```tsx
|
|
@@ -79,7 +87,9 @@ export declare function MoleculeRouterProvider(props: MoleculeRouterProviderProp
|
|
|
79
87
|
*/
|
|
80
88
|
export declare function useMoleculeRouter(): Router;
|
|
81
89
|
/**
|
|
82
|
-
* Hook to check if a path is currently active.
|
|
90
|
+
* Hook to check if a path is currently active inside any React Router router.
|
|
91
|
+
* MoleculeRouterProvider is optional; mount it only for named routes, the
|
|
92
|
+
* non-React navigate()/getRouter() bond, or onRouterReady.
|
|
83
93
|
*
|
|
84
94
|
* @param path - Path to check
|
|
85
95
|
* @param exact - Whether to require exact match
|
|
@@ -99,7 +109,9 @@ export declare function useMoleculeRouter(): Router;
|
|
|
99
109
|
*/
|
|
100
110
|
export declare function useIsActive(path: string, exact?: boolean): boolean;
|
|
101
111
|
/**
|
|
102
|
-
* Hook to get a navigate function with molecule Router options
|
|
112
|
+
* Hook to get a navigate function with molecule Router options inside any React
|
|
113
|
+
* Router router. MoleculeRouterProvider is optional; mount it only for named
|
|
114
|
+
* routes, the non-React navigate()/getRouter() bond, or onRouterReady.
|
|
103
115
|
*
|
|
104
116
|
* @returns Navigate function
|
|
105
117
|
*
|
|
@@ -117,7 +129,9 @@ export declare function useIsActive(path: string, exact?: boolean): boolean;
|
|
|
117
129
|
*/
|
|
118
130
|
export declare function useMoleculeNavigate(): Router['navigate'];
|
|
119
131
|
/**
|
|
120
|
-
* Hook to get current query params as an object.
|
|
132
|
+
* Hook to get current query params as an object inside any React Router router.
|
|
133
|
+
* MoleculeRouterProvider is optional; mount it only for named routes, the
|
|
134
|
+
* non-React navigate()/getRouter() bond, or onRouterReady.
|
|
121
135
|
*
|
|
122
136
|
* @returns Query params object
|
|
123
137
|
*
|
package/dist/hooks.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":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E,MAAM,GACX,SAAS,CAAC,MAAM,EAAE,QAAQ,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC,CA8ErD"}
|
package/dist/hooks.js
CHANGED
|
@@ -5,7 +5,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
5
5
|
* @module
|
|
6
6
|
*/
|
|
7
7
|
import { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState, } from 'react';
|
|
8
|
-
import { useLocation, useNavigate, useParams, useSearchParams } from 'react-router';
|
|
8
|
+
import { useInRouterContext, useLocation, useNavigate, useParams, useSearchParams, } from 'react-router';
|
|
9
9
|
import { t } from '@molecule/app-i18n';
|
|
10
10
|
import { setRouter } from '@molecule/app-routing';
|
|
11
11
|
import { createReactRouter } from './provider.js';
|
|
@@ -20,7 +20,8 @@ const MoleculeRouterContext = createContext(null);
|
|
|
20
20
|
* Bonding happens in an effect on mount (and again whenever the location/params
|
|
21
21
|
* change), so `@molecule/app-routing`'s `navigate()`/`getRouter()` drive THIS real
|
|
22
22
|
* React Router adapter — no manual `setRouter` wiring required. Mount it once inside
|
|
23
|
-
*
|
|
23
|
+
* any React Router router when non-React code needs the bond, named routes are
|
|
24
|
+
* configured, or `onRouterReady` is needed. The routing hooks work without this provider.
|
|
24
25
|
*
|
|
25
26
|
* @param props - The provider props (see {@link MoleculeRouterProviderProps}):
|
|
26
27
|
* `children` (rendered inside the router context), `routes` (optional named-route
|
|
@@ -75,10 +76,17 @@ export function MoleculeRouterProvider(props) {
|
|
|
75
76
|
return _jsx(MoleculeRouterContext.Provider, { value: router, children: children });
|
|
76
77
|
}
|
|
77
78
|
/**
|
|
78
|
-
* Hook to get the molecule Router
|
|
79
|
+
* Hook to get the molecule Router inside any React Router router, including
|
|
80
|
+
* BrowserRouter, HashRouter, MemoryRouter, Router, or RouterProvider from this
|
|
81
|
+
* package or React Router itself. No MoleculeRouterProvider is required.
|
|
82
|
+
*
|
|
83
|
+
* When MoleculeRouterProvider is mounted, returns its exact router with its named
|
|
84
|
+
* routes. Otherwise creates a local adapter from React Router's hooks without
|
|
85
|
+
* bonding it globally. Mount MoleculeRouterProvider for the non-React
|
|
86
|
+
* `@molecule/app-routing` navigate()/getRouter() bond or onRouterReady.
|
|
79
87
|
*
|
|
80
88
|
* @returns The molecule Router instance
|
|
81
|
-
* @throws {Error} If used outside
|
|
89
|
+
* @throws {Error} If used outside a React Router router; mount a router component.
|
|
82
90
|
*
|
|
83
91
|
* @example
|
|
84
92
|
* ```tsx
|
|
@@ -95,15 +103,23 @@ export function MoleculeRouterProvider(props) {
|
|
|
95
103
|
*/
|
|
96
104
|
export function useMoleculeRouter() {
|
|
97
105
|
const router = useContext(MoleculeRouterContext);
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
106
|
+
const inRouter = useInRouterContext();
|
|
107
|
+
if (!inRouter) {
|
|
108
|
+
throw new Error(t('routing.error.useMoleculeRouterOutsideRouter', undefined, {
|
|
109
|
+
defaultValue: 'useMoleculeRouter must be used within a React Router router. Mount BrowserRouter, HashRouter, MemoryRouter, Router, or RouterProvider.',
|
|
101
110
|
}));
|
|
102
111
|
}
|
|
103
|
-
|
|
112
|
+
// Always call the React Router hooks, including when the provider supplies the
|
|
113
|
+
// adapter. The guard above throws only for an invalid render outside any router.
|
|
114
|
+
const navigate = useNavigate();
|
|
115
|
+
const location = useLocation();
|
|
116
|
+
const params = useParams();
|
|
117
|
+
return useMemo(() => router ?? createReactRouter({ navigate, location, params }), [router, navigate, location, params]);
|
|
104
118
|
}
|
|
105
119
|
/**
|
|
106
|
-
* Hook to check if a path is currently active.
|
|
120
|
+
* Hook to check if a path is currently active inside any React Router router.
|
|
121
|
+
* MoleculeRouterProvider is optional; mount it only for named routes, the
|
|
122
|
+
* non-React navigate()/getRouter() bond, or onRouterReady.
|
|
107
123
|
*
|
|
108
124
|
* @param path - Path to check
|
|
109
125
|
* @param exact - Whether to require exact match
|
|
@@ -128,7 +144,9 @@ export function useIsActive(path, exact) {
|
|
|
128
144
|
return useMemo(() => router.isActive(path, exact), [router, path, exact, location.pathname]);
|
|
129
145
|
}
|
|
130
146
|
/**
|
|
131
|
-
* Hook to get a navigate function with molecule Router options
|
|
147
|
+
* Hook to get a navigate function with molecule Router options inside any React
|
|
148
|
+
* Router router. MoleculeRouterProvider is optional; mount it only for named
|
|
149
|
+
* routes, the non-React navigate()/getRouter() bond, or onRouterReady.
|
|
132
150
|
*
|
|
133
151
|
* @returns Navigate function
|
|
134
152
|
*
|
|
@@ -149,7 +167,9 @@ export function useMoleculeNavigate() {
|
|
|
149
167
|
return router.navigate.bind(router);
|
|
150
168
|
}
|
|
151
169
|
/**
|
|
152
|
-
* Hook to get current query params as an object.
|
|
170
|
+
* Hook to get current query params as an object inside any React Router router.
|
|
171
|
+
* MoleculeRouterProvider is optional; mount it only for named routes, the
|
|
172
|
+
* non-React navigate()/getRouter() bond, or onRouterReady.
|
|
153
173
|
*
|
|
154
174
|
* @returns Query params object
|
|
155
175
|
*
|
package/dist/hooks.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.js","sourceRoot":"","sources":["../src/hooks.tsx"],"names":[],"mappings":";AAAA;;;;GAIG;AAEH,OAAc,EACZ,aAAa,EAIb,WAAW,EACX,UAAU,EACV,SAAS,EACT,OAAO,EACP,MAAM,EACN,QAAQ,GACT,MAAM,OAAO,CAAA;AACd,OAAO,
|
|
1
|
+
{"version":3,"file":"hooks.js","sourceRoot":"","sources":["../src/hooks.tsx"],"names":[],"mappings":";AAAA;;;;GAIG;AAEH,OAAc,EACZ,aAAa,EAIb,WAAW,EACX,UAAU,EACV,SAAS,EACT,OAAO,EACP,MAAM,EACN,QAAQ,GACT,MAAM,OAAO,CAAA;AACd,OAAO,EACL,kBAAkB,EAClB,WAAW,EACX,WAAW,EACX,SAAS,EACT,eAAe,GAChB,MAAM,cAAc,CAAA;AAErB,OAAO,EAAE,CAAC,EAAE,MAAM,oBAAoB,CAAA;AACtC,OAAO,EAAE,S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of the molecule Router interface,
|
|
5
5
|
* allowing you to use molecule's routing abstractions with React Router.
|
|
6
6
|
*
|
|
7
|
+
* `useMoleculeRouter`, `useMoleculeQuery`, `useMoleculeNavigate`, and `useIsActive`
|
|
8
|
+
* work inside any React Router router (BrowserRouter, HashRouter, MemoryRouter,
|
|
9
|
+
* Router, or RouterProvider), from this package or React Router itself. No
|
|
10
|
+
* MoleculeRouterProvider is required for these hooks. Mount MoleculeRouterProvider
|
|
11
|
+
* only to bond the adapter for non-React `@molecule/app-routing` navigate()/getRouter(),
|
|
12
|
+
* supply named routes, or receive onRouterReady. Hook-created adapters remain local
|
|
13
|
+
* so multiple consumers cannot overwrite the global router bond.
|
|
14
|
+
*
|
|
7
15
|
* **Paginated or filtered page? Use `useListRoute` for its URL state.** It reads
|
|
8
16
|
* page, filters and selected views from the current URL; builds links that retain
|
|
9
17
|
* the current path/filters; and resets page when a filter or view changes. Declare
|
|
@@ -16,6 +24,7 @@
|
|
|
16
24
|
* import { BrowserRouter, MoleculeRouterProvider } from '@molecule/app-routing-react-router'
|
|
17
25
|
*
|
|
18
26
|
* function App() {
|
|
27
|
+
* // Optional: include this provider for non-React navigation or named routes.
|
|
19
28
|
* // MoleculeRouterProvider bonds the adapter automatically (calls setRouter in an
|
|
20
29
|
* // effect on mount), so @molecule/app-routing's navigate()/getRouter() drive THIS
|
|
21
30
|
* // real React Router — no manual setRouter wiring needed.
|
|
@@ -135,7 +144,7 @@
|
|
|
135
144
|
* - **Do NOT wire the exported `provider` const** in a React Router app — it is a
|
|
136
145
|
* no-hooks fallback (empty params, `window.location.href` navigation). Use
|
|
137
146
|
* `MoleculeRouterProvider` (or `createReactRouter` with hook values) instead.
|
|
138
|
-
* - The provider must live INSIDE
|
|
147
|
+
* - The provider must live INSIDE a React Router router (it calls React Router hooks).
|
|
139
148
|
* - **Import router components from this bond, never directly from React Router.**
|
|
140
149
|
* Its wrappers turn transitions off, so a navigation renders the new route in the
|
|
141
150
|
* same commit as the URL change. Import non-router APIs (`Routes`, `Route`, `Link`,
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+JG;AAEH,cAAc,YAAY,CAAA;AAC1B,cAAc,eAAe,CAAA;AAC7B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,eAAe,CAAA;AAC7B,cAAc,cAAc,CAAA;AAC5B,YAAY,EACV,WAAW,EACX,eAAe,EACf,eAAe,EACf,WAAW,EACX,iBAAiB,EACjB,gBAAgB,EAChB,mBAAmB,EACnB,eAAe,EACf,aAAa,EACb,UAAU,EACV,WAAW,EACX,YAAY,GACb,MAAM,YAAY,CAAA;AACnB,cAAc,mBAAmB,CAAA;AACjC,cAAc,gBAAgB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -4,6 +4,14 @@
|
|
|
4
4
|
* This package provides a React Router implementation of the molecule Router interface,
|
|
5
5
|
* allowing you to use molecule's routing abstractions with React Router.
|
|
6
6
|
*
|
|
7
|
+
* `useMoleculeRouter`, `useMoleculeQuery`, `useMoleculeNavigate`, and `useIsActive`
|
|
8
|
+
* work inside any React Router router (BrowserRouter, HashRouter, MemoryRouter,
|
|
9
|
+
* Router, or RouterProvider), from this package or React Router itself. No
|
|
10
|
+
* MoleculeRouterProvider is required for these hooks. Mount MoleculeRouterProvider
|
|
11
|
+
* only to bond the adapter for non-React `@molecule/app-routing` navigate()/getRouter(),
|
|
12
|
+
* supply named routes, or receive onRouterReady. Hook-created adapters remain local
|
|
13
|
+
* so multiple consumers cannot overwrite the global router bond.
|
|
14
|
+
*
|
|
7
15
|
* **Paginated or filtered page? Use `useListRoute` for its URL state.** It reads
|
|
8
16
|
* page, filters and selected views from the current URL; builds links that retain
|
|
9
17
|
* the current path/filters; and resets page when a filter or view changes. Declare
|
|
@@ -16,6 +24,7 @@
|
|
|
16
24
|
* import { BrowserRouter, MoleculeRouterProvider } from '@molecule/app-routing-react-router'
|
|
17
25
|
*
|
|
18
26
|
* function App() {
|
|
27
|
+
* // Optional: include this provider for non-React navigation or named routes.
|
|
19
28
|
* // MoleculeRouterProvider bonds the adapter automatically (calls setRouter in an
|
|
20
29
|
* // effect on mount), so @molecule/app-routing's navigate()/getRouter() drive THIS
|
|
21
30
|
* // real React Router — no manual setRouter wiring needed.
|
|
@@ -135,7 +144,7 @@
|
|
|
135
144
|
* - **Do NOT wire the exported `provider` const** in a React Router app — it is a
|
|
136
145
|
* no-hooks fallback (empty params, `window.location.href` navigation). Use
|
|
137
146
|
* `MoleculeRouterProvider` (or `createReactRouter` with hook values) instead.
|
|
138
|
-
* - The provider must live INSIDE
|
|
147
|
+
* - The provider must live INSIDE a React Router router (it calls React Router hooks).
|
|
139
148
|
* - **Import router components from this bond, never directly from React Router.**
|
|
140
149
|
* Its wrappers turn transitions off, so a navigation renders the new route in the
|
|
141
150
|
* same commit as the URL change. Import non-router APIs (`Routes`, `Route`, `Link`,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+JG;AAEH,cAAc,YAAY,CAAA;AAC1B,cAAc,eAAe,CAAA;AAC7B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,eAAe,CAAA;AAC7B,cAAc,cAAc,CAAA;AAe5B,cAAc,mBAAmB,CAAA;AACjC,cAAc,gBAAgB,CAAA"}
|