I am getting the following error when running npm run start
in the terminal.
Attempted import error: 'Redirect' is not exported from 'react-router-dom'.
I have reinstalled node_modules
, react-router-dom
, react-router
. Also restarted the terminal and my computer, but the issue persists.
My code:
import React from 'react';
import { Switch, Redirect } from 'react-router-dom';
import { RouteWithLayout } from './components';
import { Minimal as MinimalLayout } from './layouts';
import {
Login as LoginView,
Dashboard as DashboardView,
NotFound as NotFoundView
} from './views';
const Routes = () => {
return (
<Switch>
<Redirect
exact
from="/"
to="/dashboard"
/>
<RouteWithLayout
component={routeProps => <LoginView {...routeProps} data={data} />}
exact
layout={MinimalLayout}
path="/login"
/>
<Redirect to="/not-found" />
</Switch>
);
};
export default Routes;
Here is my package.json
imports:
"react-router": "^6.0.0-beta.0",
"react-router-dom": "^6.0.0-beta.0",