Skip to content

React Router Upgrade to V7 - changes ( https://reactrouter.com/upgrading/v6#upgrade-to-v7 ) #6

Description

@userresh

As per latest upgrade to V7 of React Router (https://reactrouter.com/upgrading/v6#upgrade-to-v7), we no longer need "react-router-dom" as the packages have been simplified. We can import everything from "react-router".
Note that we only need "react-router" in our package.json.

Issue:

As explained about react router in NamasteReact series( episode :07), while importing createBrowserRouter from "react-router-dom" was working fine as it was in the previous version of V6.
But now from V7 it throws an error.

Fix:

  1. Uninstall react-router-dom and install react-router to latest
  2. Replace the following code in App.js :-
    import { createBrowserRouter, RouterProvider, Outlet } from "react-router-dom";

with the below code:-
import { createBrowserRouter, RouterProvider, Outlet } from "react-router";

(P.S :- please verify the above fix )

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions