@remix-run/router 1.5.0-pre.2 → 1.6.0-pre.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 CHANGED
@@ -1,18 +1,27 @@
1
1
  # `@remix-run/router`
2
2
 
3
- ## 1.5.0-pre.2
3
+ ## 1.6.0-pre.0
4
4
 
5
- ### Patch Changes
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))
6
8
 
7
- - Fix lint issue ([#10256](https://github.com/remix-run/react-router/pull/10256))
9
+ - Example: `router.navigate("../path", { fromRouteId: "some-route" })`.
10
+ - This also applies to `router.fetch` which already receives a source route ID
8
11
 
9
- ## 1.5.0-pre.1
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
+ - 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
14
+ - This also enables `basename` support in `useFetcher` as well
10
15
 
11
16
  ### Patch Changes
12
17
 
13
- - Remove `instanceof` check for `DeferredData` to be resiliant to ESM/CJS boundaries in SSR bundling scenarios ([#10247](https://github.com/remix-run/react-router/pull/10247))
18
+ - Enhance `LoaderFunction`/`ActionFunction` return type to prevent `undefined` from being a valid return value ([#10267](https://github.com/remix-run/react-router/pull/10267))
19
+ - Ensure proper 404 error on `fetcher.load` call to a route without a `loader` ([#10345](https://github.com/remix-run/react-router/pull/10345))
20
+ - 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))
21
+ - 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))
22
+ - 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))
14
23
 
15
- ## 1.5.0-pre.0
24
+ ## 1.5.0
16
25
 
17
26
  ### Minor Changes
18
27
 
@@ -29,6 +38,7 @@
29
38
 
30
39
  - Provide fetcher submission to `shouldRevalidate` if the fetcher action redirects ([#10208](https://github.com/remix-run/react-router/pull/10208))
31
40
  - Properly handle `lazy()` errors during router initialization ([#10201](https://github.com/remix-run/react-router/pull/10201))
41
+ - Remove `instanceof` check for `DeferredData` to be resilient to ESM/CJS boundaries in SSR bundling scenarios ([#10247](https://github.com/remix-run/react-router/pull/10247))
32
42
  - Update to latest `@remix-run/web-fetch@4.3.3` ([#10216](https://github.com/remix-run/react-router/pull/10216))
33
43
 
34
44
  ## 1.4.0
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-2022
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` 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,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
- // Routes array
20
- routes: ,
21
- // History instance
22
- history,
23
- }).initialize()
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