@remix-run/router 1.5.0 → 1.6.0
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/CHANGELOG.md +22 -0
- package/LICENSE.md +3 -2
- package/README.md +34 -6
- package/dist/router.cjs.js +214 -100
- package/dist/router.cjs.js.map +1 -1
- package/dist/router.d.ts +22 -12
- package/dist/router.js +214 -100
- package/dist/router.js.map +1 -1
- package/dist/router.umd.js +214 -100
- package/dist/router.umd.js.map +1 -1
- package/dist/router.umd.min.js +2 -2
- package/dist/router.umd.min.js.map +1 -1
- package/dist/utils.d.ts +20 -3
- package/package.json +1 -1
- package/router.ts +301 -132
- package/utils.ts +25 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# `@remix-run/router`
|
|
2
2
|
|
|
3
|
+
## 1.6.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Enable relative routing in the `@remix-run/router` when providing a source route ID from which the path is relative to: ([#10336](https://github.com/remix-run/react-router/pull/10336))
|
|
8
|
+
|
|
9
|
+
- Example: `router.navigate("../path", { fromRouteId: "some-route" })`.
|
|
10
|
+
- This also applies to `router.fetch` which already receives a source route ID
|
|
11
|
+
|
|
12
|
+
- Introduce a new `@remix-run/router` `future.v7_prependBasename` flag to enable `basename` prefixing to all paths coming into `router.navigate` and `router.fetch`.
|
|
13
|
+
|
|
14
|
+
- Previously the `basename` was prepended in the React Router layer, but now that relative routing is being handled by the router we need prepend the `basename` _after_ resolving any relative paths
|
|
15
|
+
- This also enables `basename` support in `useFetcher` as well
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- Enhance `LoaderFunction`/`ActionFunction` return type to prevent `undefined` from being a valid return value ([#10267](https://github.com/remix-run/react-router/pull/10267))
|
|
20
|
+
- Ensure proper 404 error on `fetcher.load` call to a route without a `loader` ([#10345](https://github.com/remix-run/react-router/pull/10345))
|
|
21
|
+
- Deprecate the `createRouter` `detectErrorBoundary` option in favor of the new `mapRouteProperties` option for converting a framework-agnostic route to a framework-aware route. This allows us to set more than just the `hasErrorBoundary` property during route pre-processing, and is now used for mapping `Component -> element` and `ErrorBoundary -> errorElement` in `react-router`. ([#10287](https://github.com/remix-run/react-router/pull/10287))
|
|
22
|
+
- Fixed a bug where fetchers were incorrectly attempting to revalidate on search params changes or routing to the same URL (using the same logic for route `loader` revalidations). However, since fetchers have a static href, they should only revalidate on `action` submissions or `router.revalidate` calls. ([#10344](https://github.com/remix-run/react-router/pull/10344))
|
|
23
|
+
- Decouple `AbortController` usage between revalidating fetchers and the thing that triggered them such that the unmount/deletion of a revalidating fetcher doesn't impact the ongoing triggering navigation/revalidation ([#10271](https://github.com/remix-run/react-router/pull/10271))
|
|
24
|
+
|
|
3
25
|
## 1.5.0
|
|
4
26
|
|
|
5
27
|
### Minor Changes
|
package/LICENSE.md
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c) React Training 2015-2019
|
|
4
|
-
Copyright (c) Remix Software 2020-
|
|
3
|
+
Copyright (c) React Training LLC 2015-2019
|
|
4
|
+
Copyright (c) Remix Software Inc. 2020-2021
|
|
5
|
+
Copyright (c) Shopify Inc. 2022-2023
|
|
5
6
|
|
|
6
7
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
8
|
of this software and associated documentation files (the "Software"), to deal
|
package/README.md
CHANGED
|
@@ -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`
|
|
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,23 @@ 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
|
-
//
|
|
20
|
-
routes:
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
// Required properties
|
|
20
|
+
routes: [{
|
|
21
|
+
path: '/',
|
|
22
|
+
loader: ({ request, params }) => { /* ... */ },
|
|
23
|
+
children: [{
|
|
24
|
+
path: 'home',
|
|
25
|
+
loader: ({ request, params }) => { /* ... */ },
|
|
26
|
+
}]
|
|
27
|
+
},
|
|
28
|
+
history: createBrowserHistory(),
|
|
29
|
+
|
|
30
|
+
// Optional properties
|
|
31
|
+
basename, // Base path
|
|
32
|
+
mapRouteProperties, // Map framework-agnostic routes to framework-aware routes
|
|
33
|
+
future, // Future flags
|
|
34
|
+
hydrationData, // Hydration data if using server-side-rendering
|
|
35
|
+
}).initialize();
|
|
24
36
|
```
|
|
25
37
|
|
|
26
38
|
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()`;
|
|
@@ -78,6 +90,11 @@ router.navigate("/page", {
|
|
|
78
90
|
formMethod: "post",
|
|
79
91
|
formData,
|
|
80
92
|
});
|
|
93
|
+
|
|
94
|
+
// Relative routing from a source routeId
|
|
95
|
+
router.navigate("../../somewhere", {
|
|
96
|
+
fromRouteId: "active-route-id",
|
|
97
|
+
});
|
|
81
98
|
```
|
|
82
99
|
|
|
83
100
|
### Fetchers
|
|
@@ -101,7 +118,18 @@ router.fetch("key", "/page", {
|
|
|
101
118
|
|
|
102
119
|
By default, active loaders will revalidate after any navigation or fetcher mutation. If you need to kick off a revalidation for other use-cases, you can use `router.revalidate()` to re-execute all active loaders.
|
|
103
120
|
|
|
121
|
+
### Future Flags
|
|
122
|
+
|
|
123
|
+
We use _Future Flags_ in the router to help us introduce breaking changes in an opt-in fashion ahead of major releases. Please check out the [blog post][future-flags-post] and [React Router Docs][api-development-strategy] for more information on this process. The currently available future flags in `@remix-run/router` are:
|
|
124
|
+
|
|
125
|
+
| Flag | Description |
|
|
126
|
+
| ------------------------ | ------------------------------------------------------------------------- |
|
|
127
|
+
| `v7_normalizeFormMethod` | Normalize `useNavigation().formMethod` to be an uppercase HTTP Method |
|
|
128
|
+
| `v7_prependBasename` | Prepend the `basename` to incoming `router.navigate`/`router.fetch` paths |
|
|
129
|
+
|
|
104
130
|
[react-router]: https://reactrouter.com
|
|
105
131
|
[remix]: https://remix.run
|
|
106
132
|
[react-router-repo]: https://github.com/remix-run/react-router
|
|
107
133
|
[remix-routers-repo]: https://github.com/brophdawg11/remix-routers
|
|
134
|
+
[api-development-strategy]: https://reactrouter.com/en/main/guides/api-development-strategy
|
|
135
|
+
[future-flags-post]: https://remix.run/blog/future-flags
|