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}/>
答案 0 :(得分:0)
<Switch>
<Route path='/groups/:group/add' component={AddUserToGroup}/>
<MainData>
<div>
<Route path='/login' render={this.renderLogIn}/>
</div>
</MainData>
</Switch>
希望它也可以帮到你!