@c0va23/react-router-dev 7.8.3-alpha.2 → 7.9.4-patch.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/CHANGELOG.md CHANGED
@@ -3,6 +3,176 @@
3
3
  ### Patch Changes
4
4
  - Copy `server.watch` config options from `vite.config.(ts|js)` file to child vite server in development mode.
5
5
 
6
+ ## 7.9.4
7
+
8
+ ### Patch Changes
9
+
10
+ - Update `valibot` dependency to `^1.1.0` ([#14379](https://github.com/remix-run/react-router/pull/14379))
11
+
12
+ - New (unstable) `useRoute` hook for accessing data from specific routes ([#14407](https://github.com/remix-run/react-router/pull/14407))
13
+
14
+ For example, let's say you have an `admin` route somewhere in your app and you want any child routes of `admin` to all have access to the `loaderData` and `actionData` from `admin.`
15
+
16
+ ```tsx
17
+ // app/routes/admin.tsx
18
+ import { Outlet } from "react-router";
19
+
20
+ export const loader = () => ({ message: "Hello, loader!" });
21
+
22
+ export const action = () => ({ count: 1 });
23
+
24
+ export default function Component() {
25
+ return (
26
+ <div>
27
+ {/* ... */}
28
+ <Outlet />
29
+ {/* ... */}
30
+ </div>
31
+ );
32
+ }
33
+ ```
34
+
35
+ You might even want to create a reusable widget that all of the routes nested under `admin` could use:
36
+
37
+ ```tsx
38
+ import { unstable_useRoute as useRoute } from "react-router";
39
+
40
+ export function AdminWidget() {
41
+ // How to get `message` and `count` from `admin` route?
42
+ }
43
+ ```
44
+
45
+ In framework mode, `useRoute` knows all your app's routes and gives you TS errors when invalid route IDs are passed in:
46
+
47
+ ```tsx
48
+ export function AdminWidget() {
49
+ const admin = useRoute("routes/dmin");
50
+ // ^^^^^^^^^^^
51
+ }
52
+ ```
53
+
54
+ `useRoute` returns `undefined` if the route is not part of the current page:
55
+
56
+ ```tsx
57
+ export function AdminWidget() {
58
+ const admin = useRoute("routes/admin");
59
+ if (!admin) {
60
+ throw new Error(`AdminWidget used outside of "routes/admin"`);
61
+ }
62
+ }
63
+ ```
64
+
65
+ Note: the `root` route is the exception since it is guaranteed to be part of the current page.
66
+ As a result, `useRoute` never returns `undefined` for `root`.
67
+
68
+ `loaderData` and `actionData` are marked as optional since they could be accessed before the `action` is triggered or after the `loader` threw an error:
69
+
70
+ ```tsx
71
+ export function AdminWidget() {
72
+ const admin = useRoute("routes/admin");
73
+ if (!admin) {
74
+ throw new Error(`AdminWidget used outside of "routes/admin"`);
75
+ }
76
+ const { loaderData, actionData } = admin;
77
+ console.log(loaderData);
78
+ // ^? { message: string } | undefined
79
+ console.log(actionData);
80
+ // ^? { count: number } | undefined
81
+ }
82
+ ```
83
+
84
+ If instead of a specific route, you wanted access to the _current_ route's `loaderData` and `actionData`, you can call `useRoute` without arguments:
85
+
86
+ ```tsx
87
+ export function AdminWidget() {
88
+ const currentRoute = useRoute();
89
+ currentRoute.loaderData;
90
+ currentRoute.actionData;
91
+ }
92
+ ```
93
+
94
+ This usage is equivalent to calling `useLoaderData` and `useActionData`, but consolidates all route data access into one hook: `useRoute`.
95
+
96
+ Note: when calling `useRoute()` (without a route ID), TS has no way to know which route is the current route.
97
+ As a result, `loaderData` and `actionData` are typed as `unknown`.
98
+ If you want more type-safety, you can either narrow the type yourself with something like `zod` or you can refactor your app to pass down typed props to your `AdminWidget`:
99
+
100
+ ```tsx
101
+ export function AdminWidget({
102
+ message,
103
+ count,
104
+ }: {
105
+ message: string;
106
+ count: number;
107
+ }) {
108
+ /* ... */
109
+ }
110
+ ```
111
+
112
+ - Updated dependencies:
113
+ - `react-router@7.9.4`
114
+ - `@react-router/node@7.9.4`
115
+ - `@react-router/serve@7.9.4`
116
+
117
+ ## 7.9.3
118
+
119
+ ### Patch Changes
120
+
121
+ - Updated dependencies:
122
+ - `react-router@7.9.3`
123
+ - `@react-router/node@7.9.3`
124
+ - `@react-router/serve@7.9.3`
125
+
126
+ ## 7.9.2
127
+
128
+ ### Patch Changes
129
+
130
+ - Fix preset future flags being ignored during config resolution ([#14369](https://github.com/remix-run/react-router/pull/14369))
131
+
132
+ Fixes a bug where future flags defined by presets were completely ignored. The config resolution was incorrectly reading from `reactRouterUserConfig.future` instead of the merged `userAndPresetConfigs.future`, causing all preset-defined future flags to be lost.
133
+
134
+ This fix ensures presets can properly enable experimental features as intended by the preset system design.
135
+
136
+ - Add unstable support for RSC Framework Mode ([#14336](https://github.com/remix-run/react-router/pull/14336))
137
+
138
+ - Switch internal vite plugin Response logic to use `@remix-run/node-fetch-server` ([#13927](https://github.com/remix-run/react-router/pull/13927))
139
+
140
+ - Updated dependencies:
141
+ - `react-router@7.9.2`
142
+ - `@react-router/serve@7.9.2`
143
+ - `@react-router/node@7.9.2`
144
+
145
+ ## 7.9.1
146
+
147
+ ### Patch Changes
148
+
149
+ - Fix internal `Future` interface naming from `middleware` -> `v8_middleware` ([#14327](https://github.com/remix-run/react-router/pull/14327))
150
+ - Updated dependencies:
151
+ - `react-router@7.9.1`
152
+ - `@react-router/node@7.9.1`
153
+ - `@react-router/serve@7.9.1`
154
+
155
+ ## 7.9.0
156
+
157
+ ### Minor Changes
158
+
159
+ - Stabilize middleware and context APIs. ([#14215](https://github.com/remix-run/react-router/pull/14215))
160
+
161
+ We have removed the `unstable_` prefix from the following APIs and they are now considered stable and ready for production use:
162
+ - [`RouterContextProvider`](https://reactrouter.com/api/utils/RouterContextProvider)
163
+ - [`createContext`](https://reactrouter.com/api/utils/createContext)
164
+ - `createBrowserRouter` [`getContext`](https://reactrouter.com/api/data-routers/createBrowserRouter#optsgetcontext) option
165
+ - `<HydratedRouter>` [`getContext`](https://reactrouter.com/api/framework-routers/HydratedRouter#getcontext) prop
166
+
167
+ Please see the [Middleware Docs](https://reactrouter.com/how-to/middleware), the [Middleware RFC](https://github.com/remix-run/remix/discussions/7642), and the [Client-side Context RFC](https://github.com/remix-run/react-router/discussions/9856) for more information.
168
+
169
+ ### Patch Changes
170
+
171
+ - Updated dependencies:
172
+ - `react-router@7.9.0`
173
+ - `@react-router/node@7.9.0`
174
+ - `@react-router/serve@7.9.0`
175
+
6
176
  ## 7.8.2
7
177
 
8
178
  ### Patch Changes