You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/router/README.md
+11-6Lines changed: 11 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
3
3
The `@remix-run/router` package is a framework-agnostic routing package (sometimes referred to as a browser-emulator) that serves as the heart of [React Router][react-router] and [Remix][remix] and provides all the core functionality for routing coupled with data loading and data mutations. It comes with built-in handling of errors, race-conditions, interruptions, cancellations, lazy-loading data, and much, much more.
4
4
5
-
If you're using React Router, you should never `import` anything directly from the `@remix-run/router`or `react-router` packages, but you should have everything you need in either `react-router-dom` or `react-router-native`. Both of those packages re-export everything from `@remix-run/router` and `react-router`.
5
+
If you're using React Router, you should never `import` anything directly from the `@remix-run/router`- you should have everything you need in `react-router-dom`(or `react-router`/`react-router-native` if you're not rendering in the browser). All of those packages should re-export everything you would otherwise need from `@remix-run/router`.
6
6
7
7
> **Warning**
8
8
>
@@ -16,11 +16,16 @@ A Router instance can be created using `createRouter`:
16
16
// Create and initialize a router. "initialize" contains all side effects
17
17
// including history listeners and kicking off the initial data fetch
18
18
let router =createRouter({
19
-
// Routes array
20
-
routes: ,
21
-
// History instance
22
-
history,
23
-
}).initialize()
19
+
// Required properties
20
+
routes, // Routes array
21
+
history, // History instance
22
+
23
+
// Optional properties
24
+
basename, // Base path
25
+
mapRouteProperties, // Map function framework-agnostic routes to framework-aware routes
26
+
future, // Future flags
27
+
hydrationData, // Hydration data if using server-side-rendering
28
+
}).initialize();
24
29
```
25
30
26
31
Internally, the Router represents the state in an object of the following format, which is available through `router.state`. You can also register a subscriber of the signature `(state: RouterState) => void` to execute when the state updates via `router.subscribe()`;
0 commit comments