React:'Redirect'不是从'react-router-dom'导出的
2022-08-30 02:34:31
我在终端中运行时收到以下错误。npm run start
尝试导入错误:“重定向”未从“react-router-dom”导出。
我已重新安装 、 、 。已重新启动终端和计算机,但问题仍然存在。node_modules
react-router-dom
react-router
我的代码:
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;
这是我的进口:package.json
"react-router": "^6.0.0-beta.0",
"react-router-dom": "^6.0.0-beta.0",