I used a React-Router, coded this
<Router>
<div className="app">
<div className="wrapper">
<AppHeaderMain />
<Switch>
<Route exact path="/" component={Home} />
<Route path="/list/" component={List} />
<Route path="/about/" component={About} />
<Route component={NotFound} />
</Switch>
<div className="menu">
<ul>
<li><NavLink exact to="/">List</NavLink></li>
<li><NavLink to="/about/">About</NavLink></li>
</ul>
</div>
</div>
</div>
</Router>
and I have a question, is it possible to load another component based on Rout path, for example:
path="/" - load <AppHeaderMain />
path="/list/" - load <AppHeaderSubpage />
I know I could insert a AppHeader component into each single component but I would like to don't repeat some additional code which would be required to make that. I mean something like conditional including (loading) component. Is it a good practice? Maybe I must to do exactly how I wrote: include in each single component?
switchandrouteinside of<AppHeaderMain />and decide how to render it. but Krasimir answer is a better practice.