4

I have my routes like this:

<Route handler={AppContainer}>
 <Route path="login" handler={Login} />
 <Route path="signup" handler={Signup} />
 <DefaultRoute handler={Home} />
</Route>

My AppContainer:

var AppContainer = React.createClass({
  render: function () {
    return (
      <div>
        <Header />
        <RouteHandler />
      </div>
    );
  }
});

Here the Header component gets rendered in all the pages. Is there a way to avoid header in login and sign up page.

Dinesh Ramasamy
  • 930
  • 9
  • 19

1 Answers1

7

This means that your component (AppContainer) has state. Therefore you should have something like:

var AppContainer = React.createClass({
  
  // state management in here
  
  render: function () {
    let navHeader = this.state.isAuth ? <Header /> : '';
    return (
      <div>
        {navHeader}
        <RouteHandler />
      </div>
    );
  }
});
Taspina
  • 131
  • 1
  • 5