在反应中进行路由会抛出“不允许重复的道具”

时间:2020-01-27 13:39:41

标签: reactjs react-router-dom

我所有的路由都在我的app.js中完成。但是在我的路线中,同一件事我会收到多个错误。我没有通过应用程序的这一部分传递道具,所以我不确定为什么会收到这个消息。

我收到的错误


[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的路由部分

<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>

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

1 个答案:

答案 0 :(得分:3)

好像您将exact道具两次传递到每条路线。

请参见react-router docs