how to use switched routes and non switching routes together?

时间:2018-06-04 17:21:51

标签: reactjs routes switch-statement

I'm trying to switch between 2 components in react, but altogether, when my path is "login" I want any of the 2 above components to stay on screen as they are, and the "login" component appear with the other component, now my 2 components switches, but when login, it looks like the login component inside the Switch tag too.

       public renderLogIn=(props:any)=>
             (<Popup {...props} />)

      <Switch>
          <Route exact={true} path="/" component={MainData}/>
          <Route path='/groups/:group/add' component={AddUserToGroup}/>
      </Switch>
      <Route path='/login' render={this.renderLogIn}/>

1 个答案:

答案 0 :(得分:0)

感谢所有试过的人...... 我找到了适合我的答案:

          <Switch>
              <Route path='/groups/:group/add' component={AddUserToGroup}/>
              <MainData>
                  <div>
                      <Route path='/login' render={this.renderLogIn}/>
                  </div>
              </MainData>
          </Switch>

希望它也可以帮到你!