React Router/7/Update Imports

1.0.0Last update Oct 17, 2024
by@manishjha-04

In v7 the react-router and react-router-dom packages are combined so this codemod import everything directly from "react-router" except for the RouterProvider exception.

Before

import {
BrowserRouter,
Routes,
Route,
useLocation,
Link,
} from 'react-router-dom';
import { RouterProvider } from 'react-router-dom';

After

import { BrowserRouter, Routes, Route, useLocation, Link } from 'react-router';
import { RouterProvider } from 'react-router/dom';

Build custom codemods

Use AI-powered codemod studio and automate undifferentiated tasks for yourself, colleagues or the community

background illustrationGet Started Now