react-router
@remix-run/router@1.3.2
@remix-run/router@1.3.1
@remix-run/router@1.3.1-pre.0
unstable_useBlocker
hook for blocking navigations within the app's location origin (#9709)generatePath
when optional params are present (#9764)<Await>
to accept ReactNode
as children function return result (#9896)@remix-run/router@1.3.0
useId
consistency during SSR (#9805)@remix-run/router@1.2.1
useLoaderData
usage in errorElement
(#9735)@remix-run/router@1.2.0
This release introduces support for Optional Route Segments. Now, adding a ?
to the end of any path segment will make that entire segment optional. This works for both static segments and dynamic parameters.
Optional Params Examples
<Route path=":lang?/about>
will match:
/:lang/about
/about
<Route path="/multistep/:widget1?/widget2?/widget3?">
will match:
/multistep
/multistep/:widget1
/multistep/:widget1/:widget2
/multistep/:widget1/:widget2/:widget3
Optional Static Segment Example
<Route path="/home?">
will match:
/
/home
<Route path="/fr?/about">
will match:
/about
/fr/about
<Route path="prefix-:param">
, to align with how splat parameters work. If you were previously relying on this behavior then it's recommended to extract the static portion of the path at the useParams
call site: (#9506)// Old behavior at URL /prefix-123
<Route path="prefix-:id" element={<Comp /> }>
function Comp() {
let params = useParams(); // { id: '123' }
let id = params.id; // "123"
...
}
// New behavior at URL /prefix-123
<Route path=":id" element={<Comp /> }>
function Comp() {
let params = useParams(); // { id: 'prefix-123' }
let id = params.id.replace(/^prefix-/, ''); // "123"
...
}
@remix-run/router@1.1.0
@remix-run/router@1.0.5
@remix-run/router@1.0.4
useRoutes
should be able to return null
when passing locationArg
(#9485)initialEntries
type in createMemoryRouter
(#9498)@remix-run/router@1.0.3
IndexRouteObject
and NonIndexRouteObject
types to make hasErrorElement
optional (#9394)RouteObject
/RouteProps
types to surface the error in TypeScript. (#9366)@remix-run/router@1.0.2
initialEntries
(#9288)@remix-run/router@1.0.1
Whoa this is a big one! 6.4.0
brings all the data loading and mutation APIs over from Remix. Here's a quick high level overview, but it's recommended you go check out the docs, especially the feature overview and the tutorial.
New APIs
createMemoryRouter
<RouterProvider>
loader
and mutate with a Route action
errorElement
defer
and Await
Bug Fixes
useLocation
returns the scoped location inside a <Routes location>
component (#9094)Updated Dependencies
@remix-run/router@1.0.0