首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在react中路由抛出“不允许重复的道具”

在react中路由抛出“不允许重复的道具”
EN

Stack Overflow用户
提问于 2020-01-27 13:39:41
回答 1查看 2.6K关注 0票数 3

所有的路由都是在我的app.js中完成的。然而,在我的路线上,我收到了多个相同的错误-我没有通过我的应用程序的这部分道具,所以我不知道为什么我收到这个。

我收到的错误

代码语言:javascript
复制
[1] ./src/App.js
[1]   Line 70:36:   No duplicate props allowed  react/jsx-no-duplicate-props
[1]   Line 71:31:   No duplicate props allowed  react/jsx-no-duplicate-props
[1]   Line 72:39:   No duplicate props allowed  react/jsx-no-duplicate-props
[1]   Line 73:44:   No duplicate props allowed  react/jsx-no-duplicate-props
[1]   Line 78:11:   No duplicate props allowed  react/jsx-no-duplicate-props
[1]   Line 85:11:   No duplicate props allowed  react/jsx-no-duplicate-props
[1]   Line 91:11:   No duplicate props allowed  react/jsx-no-duplicate-props
[1]   Line 94:42:   No duplicate props allowed  react/jsx-no-duplicate-props
[1]   Line 95:39:   No duplicate props allowed  react/jsx-no-duplicate-props
[1]   Line 99:11:   No duplicate props allowed  react/jsx-no-duplicate-props
[1]   Line 103:47:  No duplicate props allowed  react/jsx-no-duplicate-props
[1]   Line 104:47:  No duplicate props allowed  react/jsx-no-duplicate-props
[1]   Line 108:11:  No duplicate props allowed  react/jsx-no-duplicate-props
[1]   Line 114:11:  No duplicate props allowed  react/jsx-no-duplicate-props
[1]   Line 120:11:  No duplicate props allowed  react/jsx-no-duplicate-props
[1]   Line 126:11:  No duplicate props allowed  react/jsx-no-duplicate-props
[1]   Line 132:11:  No duplicate props allowed  react/jsx-no-duplicate-props
[1]   Line 138:11:  No duplicate props allowed  react/jsx-no-duplicate-props

我的app.js的路由部分

代码语言:javascript
复制
<BrowserRouter>
      <Switch>
        <Route exact path="/reset" exact component={ResetPassword} />
        <Route exact path="/" exact component={LoginPage} />
        <Route exact path="/Register" exact component={RegisterPage} />
        <Route exact path="/confirm-email" exact component={ConfirmEmail} />

        <RegisterAuthRoute
          exact
          path="/confirm-register"
          exact
          component={ConfirmRegisterPage}
        />

        <ResetAuthRoute
          exact
          path="/confirm-Password"
          exact
          component={ConfirmPassword}
        />
        <AuthRoute
          exact
          path="/profile-update-account-details"
          exact
          component={UpdateAccountDetailsPage}
        />
        <AuthRoute exact path="/profile" exact component={ProfilePage} />
        <AuthRoute exact path="/home" exact component={Home} />
        <AuthRoute
          exact
          path="/user-questions"
          exact
          component={UserQuestions}
        />

        <AuthRoute exact path="/user-history" exact component={History} />
        <AuthRoute exact path="/admin-center" exact component={AdminCenter} />
        <AuthRoute
          exact
          path="/admin-question-editor"
          exact
          component={AdminQuestionEditor}
        />
        <AuthRoute
          exact
          path="/admin-view-users"
          exact
          component={AdminViewUsers}
        />
        <AuthRoute
          exact
          path="/admin-view-users-severity-high"
          exact
          component={AdminViewUsersSeverityHigh}
        />
        <AuthRoute
          exact
          path="/admin-view-users-severity-medium"
          exact
          component={AdminViewUsersSeverityMedium}
        />
        <AuthRoute
          exact
          path="/admin-view-users-severity-completed"
          exact
          component={AdminViewUsersSeverityCompleted}
        />
        <AuthRoute
          exact
          path="/admin-view-users"
          exact
          component={AdminViewUsers}
        />
      </Switch>
    </BrowserRouter>

本质上问题是。为什么我会收到这个错误?如何解决此错误?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-01-27 13:47:49

看起来你要两次把exact道具传递到每条路线。

详见react路由器文档

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/59932342

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档