首页 > 解决方案 > 失败的道具类型:提供给“重定向”的无效道具“到”

问题描述

我的 app.js 看起来像这样:

export default function App() {
  return (
    <BrowserRouter>
      <Switch>
        <Route path="/auth" component={AuthenticationLayout} />
        <Route path="/dash" component={DashboardLayout} />

        <Route exact path="/" render={() => (
          <Redirect to={AuthenticationLayout} />
        )}/>
      </Switch>
    </BrowserRouter>
  );
}

Can't undersatnd 有什么问题

建议?

标签: reactjsreact-routerreact-router-dom

解决方案


重定向是导航到一个新位置,to接受要重定向到的 URL,你可以这样写:

<Route exact path="/" render={() => (
      <Redirect to="/auth" />
    )}/>

推荐阅读