chore(deps): update dependency react-router to v7.3.0 #2991
+6
−6
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR contains the following updates:
7.2.0
->7.3.0
Release Notes
remix-run/react-router (react-router)
v7.3.0
Compare Source
Minor Changes
Add
fetcherKey
as a parameter topatchRoutesOnNavigation
(#13061)fetcher
calls to undiscovered routes, this mismatch will trigger a document reload of the current pathPatch Changes
Skip resource route flow in dev server in SPA mode (#13113)
Support middleware on routes (unstable) (#12941)
Middleware is implemented behind a
future.unstable_middleware
flag. To enable, you must enable the flag and the types in yourreact-router-config.ts
file:clientMiddleware
that we will be addressing this before a stable release.context
parameter passed to yourloader
/action
functions - see below for more information.Once enabled, routes can define an array of middleware functions that will run sequentially before route handlers run. These functions accept the same parameters as
loader
/action
plus an additionalnext
parameter to run the remaining data pipeline. This allows middlewares to perform logic before and after handlers execute.Here's a simple example of a client-side logging middleware that can be placed on the root route:
Note that in the above example, the
next
/middleware
functions don't return anything. This is by design as on the client there is no "response" to send over the network like there would be for middlewares running on the server. The data is all handled behind the scenes by the statefulrouter
.For a server-side middleware, the
next
function will return the HTTPResponse
that React Router will be sending across the wire, thus giving you a chance to make changes as needed. You may throw a new response to short circuit and respond immediately, or you may return a new or altered response to override the default returned bynext()
.You can throw a
redirect
from a middleware to short circuit any remaining processing:Note that in cases like this where you don't need to do any post-processing you don't need to call the
next
function or return aResponse
.Here's another example of using a server middleware to detect 404s and check the CMS for a redirect:
context
parameterWhen middleware is enabled, your application will use a different type of
context
parameter in your loaders and actions to provide better type safety. Instead ofAppLoadContext
,context
will now be an instance ofContextProvider
that you can use with type-safe contexts (similar toReact.createContext
):If you are using a custom server with a
getLoadContext
function, the return value for initial context values passed from the server adapter layer is no longer an object and should now return anunstable_InitialContext
(Map<RouterContext, unknown>
):Fix types for loaderData and actionData that contained
Record
s (#13139)UNSTABLE(BREAKING):
unstable_SerializesTo
added a way to register custom serialization types in Single Fetch for other library and framework authors like Apollo.It was implemented with branded type whose branded property that was made optional so that casting arbitrary values was easy:
However, this broke type inference in
loaderData
andactionData
for anyRecord
types as those would now (incorrectly) matchunstable_SerializesTo
.This affected all users, not just those that depended on
unstable_SerializesTo
.To fix this, the branded property of
unstable_SerializesTo
is marked as required instead of optional.For library and framework authors using
unstable_SerializesTo
, you may need to addas unknown
casts before casting tounstable_SerializesTo
.[REMOVE] Remove middleware depth logic and always call middlware for all matches (#13172)
Fix single fetch
_root.data
requests when abasename
is used (#12898)Add
context
support to client side data routers (unstable) (#12941)Your application
loader
andaction
functions on the client will now receive acontext
parameter. This is an instance ofunstable_RouterContextProvider
that you use with type-safe contexts (similar toReact.createContext
) and is most useful with the correspondingmiddleware
/clientMiddleware
API's:Similar to server-side requests, a fresh
context
will be created per navigation (orfetcher
call). If you have initial data you'd like to populate in the context for every request, you can provide anunstable_getContext
function at the root of your app:createBrowserRouter(routes, { unstable_getContext })
<HydratedRouter unstable_getContext>
This function should return an value of type
unstable_InitialContext
which is aMap<unstable_RouterContext, unknown>
of context's and initial values:Configuration
📅 Schedule: Branch creation - "* * * * 0,6" (UTC), Automerge - At any time (no schedule defined).
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR was generated by Mend Renovate. View the repository job log.
This PR contains the following updates:
7.2.0
->7.3.0
Release Notes
remix-run/react-router (react-router)
v7.3.0
Compare Source
Minor Changes
Add
fetcherKey
as a parameter topatchRoutesOnNavigation
(#13061)fetcher
calls to undiscovered routes, this mismatch will trigger a document reload of the current pathPatch Changes
Skip resource route flow in dev server in SPA mode (#13113)
Support middleware on routes (unstable) (#12941)
Middleware is implemented behind a
future.unstable_middleware
flag. To enable, you must enable the flag and the types in yourreact-router-config.ts
file:clientMiddleware
that we will be addressing this before a stable release.context
parameter passed to yourloader
/action
functions - see below for more information.Once enabled, routes can define an array of middleware functions that will run sequentially before route handlers run. These functions accept the same parameters as
loader
/action
plus an additionalnext
parameter to run the remaining data pipeline. This allows middlewares to perform logic before and after handlers execute.Here's a simple example of a client-side logging middleware that can be placed on the root route:
Note that in the above example, the
next
/middleware
functions don't return anything. This is by design as on the client there is no "response" to send over the network like there would be for middlewares running on the server. The data is all handled behind the scenes by the statefulrouter
.For a server-side middleware, the
next
function will return the HTTPResponse
that React Router will be sending across the wire, thus giving you a chance to make changes as needed. You may throw a new response to short circuit and respond immediately, or you may return a new or altered response to override the default returned bynext()
.You can throw a
redirect
from a middleware to short circuit any remaining processing:Note that in cases like this where you don't need to do any post-processing you don't need to call the
next
function or return aResponse
.Here's another example of using a server middleware to detect 404s and check the CMS for a redirect:
context
parameterWhen middleware is enabled, your application will use a different type of
context
parameter in your loaders and actions to provide better type safety. Instead ofAppLoadContext
,context
will now be an instance ofContextProvider
that you can use with type-safe contexts (similar toReact.createContext
):If you are using a custom server with a
getLoadContext
function, the return value for initial context values passed from the server adapter layer is no longer an object and should now return anunstable_InitialContext
(Map<RouterContext, unknown>
):Fix types for loaderData and actionData that contained
Record
s (#13139)UNSTABLE(BREAKING):
unstable_SerializesTo
added a way to register custom serialization types in Single Fetch for other library and framework authors like Apollo.It was implemented with branded type whose branded property that was made optional so that casting arbitrary values was easy:
However, this broke type inference in
loaderData
andactionData
for anyRecord
types as those would now (incorrectly) matchunstable_SerializesTo
.This affected all users, not just those that depended on
unstable_SerializesTo
.To fix this, the branded property of
unstable_SerializesTo
is marked as required instead of optional.For library and framework authors using
unstable_SerializesTo
, you may need to addas unknown
casts before casting tounstable_SerializesTo
.[REMOVE] Remove middleware depth logic and always call middlware for all matches (#13172)
Fix single fetch
_root.data
requests when abasename
is used (#12898)Add
context
support to client side data routers (unstable) (#12941)Your application
loader
andaction
functions on the client will now receive acontext
parameter. This is an instance ofunstable_RouterContextProvider
that you use with type-safe contexts (similar toReact.createContext
) and is most useful with the correspondingmiddleware
/clientMiddleware
API's:Similar to server-side requests, a fresh
context
will be created per navigation (orfetcher
call). If you have initial data you'd like to populate in the context for every request, you can provide anunstable_getContext
function at the root of your app:createBrowserRouter(routes, { unstable_getContext })
<HydratedRouter unstable_getContext>
This function should return an value of type
unstable_InitialContext
which is aMap<unstable_RouterContext, unknown>
of context's and initial values:Configuration
📅 Schedule: Branch creation - "* * * * 0,6" (UTC), Automerge - At any time (no schedule defined).
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR was generated by Mend Renovate. View the repository job log.