🐊Putout plugin adds ability to migrate to latest version of react router. Not bundled.
npm i putout @putout/plugin-react-router -D
Update .putout.json with:
{
"plugins": [
"react-router"
]
}Here is list of rules:
{
"rules": {
"react-router/convert-switch-to-routers": "on",
"react-router/convert-component-to-element": "on"
}
}ReactRouter v6 uses Routers instead of Switch. Check out in 🐊Putout Editor.
const {
Route,
Switch,
} = require('react-router');
const routes = () => (
<Switch>
<Route exact path="/login" component={Login}/>
<Route exact path="/join" component={Join}/>
</Switch>
);const {
Route,
Routes,
} = require('react-router');
const routes = () => (
<Routes>
<Route exact path="/login" component={Login}/>
<Route exact path="/join" component={Join}/>
</Routes>
);ReactRouter v6 uses element instead of component. Check out in 🐊Putout Editor.
<Route path="/" component={Home}/>;<Route path="/" element={<Home/>}/>;MIT