I'm a beginner on react and I have the next problem that I can't solve yet: I want to render an <NavBar/>
in every routes components but the Home. I have the following code that doesn't solve anything:
const App = props => {
function getBar() {
if(props.location === "/"){
return <NavBar/>
}
};
return (
<Router>
<div className="App">
{getBar()}
<Switch>
<Route path="/" exact component={Home} />
<Route path="/feed" component={Feed} />
<Route path="/profile" component={Profile} />
<Route path="/newPost" component={NewPost}/>
</Switch>
</div>
</Router>
);
}
Aucun commentaire:
Enregistrer un commentaire