React Router/6/Migrate StaticRouter Import
Last update
Dec 17, 2024
This codemod updates imports of StaticRouter
to use the react-router-dom/server
package instead of react-router-dom
, in line with updated React Router requirements.
Before
import { BrowserRouter, Route, StaticRouter } from "react-router-dom";
After
import { BrowserRouter, Route } from "react-router-dom";import { StaticRouter } from "react-router-dom/server";
This codemod ensures compatibility with the latest React Router version by splitting StaticRouter
imports into the correct package. Other imports from react-router-dom
remain unaffected.
Build custom codemods
Use AI-powered codemod studio and automate undifferentiated tasks for yourself, colleagues or the community