Switch Page without content from root page React

109 views Asked by At

enter image description hereI wanna switch from root ("/") to /login but I wanna that the content from root Page not in /register is there. I wanna an new Page without content from the root page!! I tried everthing, rlly!! I have no clue anymore ;(

Maybe u are better than me :D

My Code:

export default class App extends Component {
render() {
    return (
        <Router>
            <div>
                <Route path="/" component={Gui}/>
                <Route path="/register" component={Register}/>
            </div>
        </Router>
    );
}

}

1

There are 1 answers

0
AKX On

I'm assuming you're using react-router.

Use the <Switch> component to only render the first matching route.

return (
  <Router>
    <Switch>
      <Route path="/register" component={Register} />
      <Route path="/" exact component={Gui} />
    </Switch>
  </Router>
);