Breaking changes - React Router integration ONLY
To avoid runtime errors due to React Router versions mismatch, it's now recommended to:
- Upgrade
react-router-dom
tov7+
- Replace
react-router-dom
package withreact-router
Here are the upgrade steps from the upgrade guide to v7 at React Router docs:
- Upgrade
react-router-dom
tov7+
npm install react-router-dom@latest
- Replace
react-router-dom
withreact-router
npm uninstall react-router-dom npm install react-router@latest
- Update imports
-import { useLocation } from 'react-router-dom' +import { useLocation } from 'react-router'Instead of manually updating imports, you can use this command. Make sure your git working tree is clean though so you can revert if it doesn't work as expected.
find ./path/to/src \( -name "*.tsx" -o -name "*.ts" -o -name "*.js" -o -name "*.jsx" \) -type f -exec sed -i '' 's|from "react-router-dom"|from "react-router"|g' {} +If you have GNU sed installed (most Linux distributions), use this command instead:
find ./path/to/src \( -name "*.tsx" -o -name "*.ts" -o -name "*.js" -o -name "*.jsx" \) -type f -exec sed -i 's|from "react-router-dom"|from "react-router"|g' {} +
Commits
- feat: replace
react-router-dom
withreact-router
0d314b0 by @oedotme - chore: update to
react-router-dom@7
c42a12b by @oedotme - chore: update packages 403b0fd by @oedotme
Changelog: v1.19.11...v1.20.0