Skip to content

Releases: remix-run/react-router

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/[email protected]@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:

Full Changelog: https://github.com/remix-run/react-router/compare/[email protected]@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/[email protected]@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/[email protected]@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/[email protected]@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)

v1.0.0

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

This is the first stable release of @remix-run/router, which provides all the underlying routing and data loading/mutation logic for react-router. You should not be using this package directly unless you are authoring a routing library similar to react-router.

For an overview of the features provided by react-router, we recommend you go check out the docs, especially the feature overview and the tutorial.

For an overview of the features provided by @remix-run/router, please check out the README.

[email protected]

08 Sep 22:16
e3d4596
Compare
Choose a tag to compare
[email protected] Pre-release
Pre-release

Patch Changes

  • fix: remove internal router singleton (#9227)

    This change removes the internal module-level routerSingleton we create and maintain inside our data routers since it was causing a number of headaches for non-simple use cases:

    • Unit tests are a pain because you need to find a way to reset the singleton in-between tests
      • Use use a _resetModuleScope singleton for our tests
      • ...but this isn't exposed to users who may want to do their own tests around our router
    • The JSX children <Route> objects cause non-intuitive behavior based on idiomatic react expectations
      • Conditional runtime <Route>'s won't get picked up
      • Adding new <Route>'s during local dev won't get picked up during HMR
      • Using external state in your elements doesn't work as one might expect (see #9225)

    Instead, we are going to lift the singleton out into user-land, so that they create the router singleton and manage it outside the react tree - which is what react 18 is encouraging with useSyncExternalStore anyways! This also means that since users create the router - there's no longer any difference in the rendering aspect for memory/browser/hash routers (which only impacts router/history creation) - so we can get rid of those and trim to a simple RouterProvider

    // Before
    function App() {
      <DataBrowserRouter>
        <Route path="/" element={<Layout />}>
          <Route index element={<Home />}>
        </Route>
      <DataBrowserRouter>
    }
    
    // After
    let router = createBrowserRouter([{
      path: "/",
      element: <Layout />,
      children: [{
        index: true,
        element: <Home />,
      }]
    }]);
    
    function App() {
      return <RouterProvider router={router} />
    }

    If folks still prefer the JSX notation, they can leverage createRoutesFromElements (aliased from createRoutesFromChildren since they are not "children" in this usage):

    let routes = createRoutesFromElements(
      <Route path="/" element={<Layout />}>
        <Route index element={<Home />}>
      </Route>
    );
    let router = createBrowserRouter(routes);
    
    function App() {
      return <RouterProvider router={router} />
    }

    And now they can also hook into HMR correctly for router disposal:

    if (import.meta.hot) {
      import.meta.hot.dispose(() => router.dispose());
    }
    

    And finally since <RouterProvider> accepts a router, it makes unit testing easer since you can create a fresh router with each test.

    Removed APIs

    • <DataMemoryRouter>
    • <DataBrowserRouter>
    • <DataHashRouter>
    • <DataRouterProvider>
    • <DataRouter>

    Modified APIs

    • createMemoryRouter/createBrowserRouter/createHashRouter used to live in @remix-run/router to prevent devs from needing to create their own history. These are now moved to react-router/react-router-dom and handle the RouteObject -> AgnosticRouteObject conversion.

    Added APIs

    • <RouterProvider>
    • createRoutesFromElements (alias of createRoutesFromChildren)
  • Updated dependencies

[email protected]

08 Sep 22:16
e3d4596
Compare
Choose a tag to compare
[email protected] Pre-release
Pre-release

Patch Changes