I'm trying to toggle a few components based on route. I do get it to work on a refresh but not a navigate. Anybody know what I'm missing and doing wrong here?
import { BrowserRouter as Router, withRouter } from "react-router-dom";
class App extends Component {
render() {
return (
<Router>
<div className="App">
pathname: {(this.props.location.pathname)}
{!this.props.location.pathname.includes('/target') ? <TopBar childProps={childProps} /> : null}
{!this.props.location.pathname.includes('/target') ? <Header /> : null}
{this.props.location.pathname.includes('/target') ? <SecondaryHeader /> : null}
<Routes childProps={childProps} />
<Footer />
</div>
</Router>
)
}
}
export default withRouter(App)