Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(deps): update dependency react-router-dom to v6.21.2 - autoclosed #226

Closed
wants to merge 1 commit into from

Conversation

renovate[bot]
Copy link
Contributor

@renovate renovate bot commented Nov 6, 2023

Mend Renovate

This PR contains the following updates:

Package Change Age Adoption Passing Confidence
react-router-dom (source) 6.18.0 -> 6.21.2 age adoption passing confidence

Release Notes

remix-run/react-router (react-router-dom)

v6.21.2

Compare Source

v6.21.1

Compare Source

Patch Changes

v6.21.0

Compare Source

Minor Changes
  • Add a new future.v7_relativeSplatPath flag to implement a breaking bug fix to relative routing when inside a splat route. (#​11087)

    This fix was originally added in #​10983 and was later reverted in #​11078 because it was determined that a large number of existing applications were relying on the buggy behavior (see #​11052)

    The Bug
    The buggy behavior is that without this flag, the default behavior when resolving relative paths is to ignore any splat (*) portion of the current route path.

    The Background
    This decision was originally made thinking that it would make the concept of nested different sections of your apps in <Routes> easier if relative routing would replace the current splat:

    <BrowserRouter>
      <Routes>
        <Route path="/" element={<Home />} />
        <Route path="dashboard/*" element={<Dashboard />} />
      </Routes>
    </BrowserRouter>

    Any paths like /dashboard, /dashboard/team, /dashboard/projects will match the Dashboard route. The dashboard component itself can then render nested <Routes>:

    function Dashboard() {
      return (
        <div>
          <h2>Dashboard</h2>
          <nav>
            <Link to="/">Dashboard Home</Link>
            <Link to="team">Team</Link>
            <Link to="projects">Projects</Link>
          </nav>
    
          <Routes>
            <Route path="/" element={<DashboardHome />} />
            <Route path="team" element={<DashboardTeam />} />
            <Route path="projects" element={<DashboardProjects />} />
          </Routes>
        </div>
      );
    }

    Now, all links and route paths are relative to the router above them. This makes code splitting and compartmentalizing your app really easy. You could render the Dashboard as its own independent app, or embed it into your large app without making any changes to it.

    The Problem

    The problem is that this concept of ignoring part of a path breaks a lot of other assumptions in React Router - namely that "." always means the current location pathname for that route. When we ignore the splat portion, we start getting invalid paths when using ".":

    // If we are on URL /dashboard/team, and we want to link to /dashboard/team:
    function DashboardTeam() {
      // ❌ This is broken and results in <a href="/dashboard">
      return <Link to=".">A broken link to the Current URL</Link>;
    
      // ✅ This is fixed but super unintuitive since we're already at /dashboard/team!
      return <Link to="./team">A broken link to the Current URL</Link>;
    }

    We've also introduced an issue that we can no longer move our DashboardTeam component around our route hierarchy easily - since it behaves differently if we're underneath a non-splat route, such as /dashboard/:widget. Now, our "." links will, properly point to ourself inclusive of the dynamic param value so behavior will break from it's corresponding usage in a /dashboard/* route.

    Even worse, consider a nested splat route configuration:

    <BrowserRouter>
      <Routes>
        <Route path="dashboard">
          <Route path="*" element={<Dashboard />} />
        </Route>
      </Routes>
    </BrowserRouter>

    Now, a <Link to="."> and a <Link to=".."> inside the Dashboard component go to the same place! That is definitely not correct!

    Another common issue arose in Data Routers (and Remix) where any <Form> should post to it's own route action if you the user doesn't specify a form action:

    let router = createBrowserRouter({
      path: "/dashboard",
      children: [
        {
          path: "*",
          action: dashboardAction,
          Component() {
            // ❌ This form is broken!  It throws a 405 error when it submits because
            // it tries to submit to /dashboard (without the splat value) and the parent
            // `/dashboard` route doesn't have an action
            return <Form method="post">...</Form>;
          },
        },
      ],
    });

    This is just a compounded issue from the above because the default location for a Form to submit to is itself (".") - and if we ignore the splat portion, that now resolves to the parent route.

    The Solution
    If you are leveraging this behavior, it's recommended to enable the future flag, move your splat to it's own route, and leverage ../ for any links to "sibling" pages:

    <BrowserRouter>
      <Routes>
        <Route path="dashboard">
          <Route index path="*" element={<Dashboard />} />
        </Route>
      </Routes>
    </BrowserRouter>
    
    function Dashboard() {
      return (
        <div>
          <h2>Dashboard</h2>
          <nav>
            <Link to="..">Dashboard Home</Link>
            <Link to="../team">Team</Link>
            <Link to="../projects">Projects</Link>
          </nav>
    
          <Routes>
            <Route path="/" element={<DashboardHome />} />
            <Route path="team" element={<DashboardTeam />} />
            <Route path="projects" element={<DashboardProjects />} />
          </Router>
        </div>
      );
    }

    This way, . means "the full current pathname for my route" in all cases (including static, dynamic, and splat routes) and .. always means "my parents pathname".

Patch Changes

v6.20.1

Compare Source

Patch Changes

v6.20.0

Compare Source

Minor Changes
  • Export the PathParam type from the public API (#​10719)
Patch Changes

v6.19.0

Compare Source

Minor Changes
  • Add unstable_flushSync option to useNavigate/useSumbit/fetcher.load/fetcher.submit to opt-out of React.startTransition and into ReactDOM.flushSync for state updates (#​11005)
  • Allow unstable_usePrompt to accept a BlockerFunction in addition to a boolean (#​10991)
Patch Changes
  • Fix issue where a changing fetcher key in a useFetcher that remains mounted wasn't getting picked up (#​11009)
  • Fix useFormAction which was incorrectly inheriting the ?index query param from child route action submissions (#​11025)
  • Fix NavLink active logic when to location has a trailing slash (#​10734)
  • Updated dependencies:

Configuration

📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - "after 10pm every weekday,before 5am every weekday,every weekend" (UTC).

🚦 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.


  • If you want to rebase/retry this PR, check this box

This PR has been generated by Mend Renovate. View repository job log here.

@renovate renovate bot added the dependencies Pull requests that update a dependency file label Nov 6, 2023
@renovate renovate bot force-pushed the renovate/react-router-monorepo branch 4 times, most recently from fd05a18 to aaa6588 Compare November 6, 2023 13:20
@renovate renovate bot changed the title fix(deps): update dependency react-router-dom to v6.18.0 fix(deps): update dependency react-router-dom to v6.18.0 - autoclosed Nov 14, 2023
@renovate renovate bot closed this Nov 14, 2023
@renovate renovate bot deleted the renovate/react-router-monorepo branch November 14, 2023 07:25
@renovate renovate bot changed the title fix(deps): update dependency react-router-dom to v6.18.0 - autoclosed fix(deps): update dependency react-router-dom to v6.18.0 Nov 16, 2023
@renovate renovate bot reopened this Nov 16, 2023
@renovate renovate bot restored the renovate/react-router-monorepo branch November 16, 2023 14:58
@renovate renovate bot changed the title fix(deps): update dependency react-router-dom to v6.18.0 fix(deps): update dependency react-router-dom to v6.19.0 Nov 16, 2023
@renovate renovate bot force-pushed the renovate/react-router-monorepo branch from aaa6588 to b687e75 Compare November 16, 2023 14:58
@renovate renovate bot changed the title fix(deps): update dependency react-router-dom to v6.19.0 fix(deps): update dependency react-router-dom to v6.20.0 Nov 22, 2023
@renovate renovate bot force-pushed the renovate/react-router-monorepo branch from b687e75 to f57f394 Compare November 22, 2023 17:36
@renovate renovate bot changed the title fix(deps): update dependency react-router-dom to v6.20.0 fix(deps): update dependency react-router-dom to v6.20.1 Dec 1, 2023
@renovate renovate bot force-pushed the renovate/react-router-monorepo branch 2 times, most recently from f1e7ef6 to 353adfe Compare December 4, 2023 08:20
@renovate renovate bot force-pushed the renovate/react-router-monorepo branch 3 times, most recently from 1631d9e to fff099e Compare December 13, 2023 22:34
@renovate renovate bot changed the title fix(deps): update dependency react-router-dom to v6.20.1 fix(deps): update dependency react-router-dom to v6.21.0 Dec 13, 2023
@renovate renovate bot force-pushed the renovate/react-router-monorepo branch from fff099e to e978651 Compare December 21, 2023 20:07
@renovate renovate bot changed the title fix(deps): update dependency react-router-dom to v6.21.0 fix(deps): update dependency react-router-dom to v6.21.1 Dec 21, 2023
@renovate renovate bot force-pushed the renovate/react-router-monorepo branch 3 times, most recently from 714259d to a0a5a3e Compare January 11, 2024 10:04
@renovate renovate bot changed the title fix(deps): update dependency react-router-dom to v6.21.1 fix(deps): update dependency react-router-dom to v6.21.2 Jan 11, 2024
@renovate renovate bot force-pushed the renovate/react-router-monorepo branch from a0a5a3e to b884ec8 Compare January 11, 2024 18:55
@renovate renovate bot changed the title fix(deps): update dependency react-router-dom to v6.21.2 fix(deps): update dependency react-router-dom to v6.21.2 - autoclosed Jan 15, 2024
@renovate renovate bot closed this Jan 15, 2024
@renovate renovate bot deleted the renovate/react-router-monorepo branch January 15, 2024 14:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0 participants