Skip to content

Releases: remix-run/react-router

v6.6.1

23 Dec 16:01
baf69f0
Compare
Choose a tag to compare

What's Changed

  • Include submission info in shouldRevalidate on action redirects (#9777, #9782)
  • Reset actionData on action redirect to current location (#9772)

Full Changelog: https://github.com/remix-run/react-router/compare/react-router@6.6.0...react-router@6.6.1

v6.6.0

21 Dec 18:37
c3c2f29
Compare
Choose a tag to compare

What's Changed

This minor release is primarily to stabilize our SSR APIs for Data Routers now that we've wired up the new RouterProvider in Remix as part of the React Router-ing Remix work.

Minor Changes

  • Remove unstable_ prefix from createStaticHandler/createStaticRouter/StaticRouterProvider (#9738)
  • Add useBeforeUnload() hook (#9664)

Patch Changes

  • Support uppercase <Form method> and useSubmit method values (#9664)
  • Fix <button formmethod> form submission overriddes (#9664)
  • Fix explicit replace on submissions and PUSH on submission to new paths (#9734)
  • Prevent useLoaderData usage in errorElement (#9735)
  • Proper hydration of Error objects from StaticRouterProvider (#9664)
  • Skip initial scroll restoration for SSR apps with hydrationData (#9664)
  • Fix a few bugs where loader/action data wasn't properly cleared on errors (#9735)

Full Changelog: https://github.com/remix-run/react-router/compare/react-router@6.5.0...react-router@6.6.0

v6.5.0

16 Dec 17:42
1b28f4c
Compare
Choose a tag to compare

What's Changed

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

Minor Changes

  • Allows optional routes and optional static segments (#9650)

Patch Changes

  • Stop incorrectly matching on partial named parameters, i.e. <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"
  ...
}
  • Persist headers on loader request's after SSR document action request (#9721)
  • Fix requests sent to revalidating loaders so they reflect a GET request (#9660)
  • Fix issue with deeply nested optional segments (#9727)
  • GET forms now expose a submission on the loading navigation (#9695)
  • Fix error boundary tracking for multiple errors bubbling to the same boundary (#9702)

Full Changelog: https://github.com/remix-run/react-router/compare/react-router@6.4.5...react-router@6.5.0

v6.4.5

07 Dec 18:29
87ced69
Compare
Choose a tag to compare

What's Changed

  • Fix requests sent to revalidating loaders so they reflect a GET request (#9680)
  • Remove instanceof Response checks in favor of isResponse (#9690)
  • Fix URL creation in Cloudflare Pages or other non-browser-environments (#9682, #9689)
  • Add requestContext support to static handler query/queryRoute (#9696)
    • Note that the unstable API of queryRoute(path, routeId) has been changed to queryRoute(path, { routeId, requestContext })

Full Changelog: https://github.com/remix-run/react-router/compare/react-router@6.4.4...react-router@6.4.5

v6.4.4

30 Nov 20:16
12e7c28
Compare
Choose a tag to compare

What's Changed

  • Throw an error if an action/loader function returns undefined as revalidations need to know whether the loader has previously been executed. undefined also causes issues during SSR stringification for hydration. You should always ensure your loader/action returns a value, and you may return null if you don't wish to return anything. (#9511)
  • Properly handle redirects to external domains (#9590, #9654)
  • Preserve the HTTP method on 307/308 redirects (#9597)
  • Support basename in static data routers (#9591)
  • Enhanced ErrorResponse bodies to contain more descriptive text in internal 403/404/405 scenarios
  • Fix issues with encoded characters in NavLink and descendant <Routes> (#9589, #9647)
  • Properly serialize/deserialize ErrorResponse instances when using built-in hydration (#9593)
  • Support basename in static data routers (#9591)
  • Updated dependencies:
    • @remix-run/router@1.0.4
    • react-router@6.4.4

Full Changelog: https://github.com/remix-run/react-router/compare/react-router-dom@6.4.3...react-router-dom@6.4.4

v6.4.3

01 Nov 15:49
54c3e39
Compare
Choose a tag to compare

What's Changed

  • Generate correct <a href> values when using createHashRouter (#9409)
  • Better handle encoding/matching with special characters in URLs and route paths (#9477, #9496)
  • Generate correct formAction pathnames when an index route also has a path (#9486)
  • Respect relative=path prop on NavLink (#9453)
  • Fix NavLink behavior for root urls (#9497)
  • useRoutes should be able to return null when passing locationArg (#9485)
  • Fix initialEntries type in createMemoryRouter (#9498)
  • Support basename and relative routing in loader/action redirects (#9447)
  • Ignore pathless layout routes when looking for proper submission action function (#9455)
  • Add UMD build for @remix-run/router (#9446)
  • Fix createURL in local file execution in Firefox (#9464)

New Contributors

Full Changelog: https://github.com/remix-run/react-router/compare/react-router@6.4.2...react-router@6.4.3

v6.4.2

06 Oct 16:01
Compare
Choose a tag to compare

What's Changed

  • Respect basename in useFormAction (#9352)
  • Fix IndexRouteObject and NonIndexRouteObject types to make hasErrorElement optional (#9394)
  • Enhance console error messages for invalid usage of data router hooks (#9311)
  • If an index route has children, it will result in a runtime error. We have strengthened our RouteObject/RouteProps types to surface the error in TypeScript. (#9366)

Full Changelog: https://github.com/remix-run/react-router/compare/react-router@6.4.1...react-router@6.4.2

v5.3.4

02 Oct 17:08
Compare
Choose a tag to compare

We removed the mini-create-react-context dependency, moving it into an internal module to eliminate peer dependency warnings for users on React 18 (#9382).

Full Changelog: v5.3.3...v5.3.4

v6.4.1

22 Sep 15:53
Compare
Choose a tag to compare

What's Changed

Bug Fixes

  • Preserve state from initialEntries (#9288)
  • Preserve ?index for fetcher get submissions to index routes (#9312)

Full Changelog: https://github.com/remix-run/react-router/compare/react-router@6.4.0...react-router@6.4.1

v6.4.0

13 Sep 19:48
87851fb
Compare
Choose a tag to compare

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

  • Create your router with createMemoryRouter
  • Render your router with <RouterProvider>
  • Load data with a Route loader and mutate with a Route action
  • Handle errors with Route errorElement
  • Defer non-critical data with defer and Await

react-router-dom APIs

  • Create your router with createBrowserRouter/createHashRouter
  • Submit data with the new <Form> component
  • Perform in-page data loads and mutations with useFetcher()
  • Defer non-critical data with defer and Await
  • Manage scroll position with <ScrollRestoration>
  • Perform path-relative navigations with <Link relative="path"> (#9160)

Bug Fixes

  • Path resolution is now trailing slash agnostic (#8861)
  • useLocation returns the scoped location inside a <Routes location> component (#9094)
  • Respect the <Link replace> prop if it is defined (#8779)