I am using React Router Native I want to hide a component on a specific path
<NativeRouter history={nativeHistory}>
<Route exact path="/" component={Home} />
<Route path="/about" component={About} />
<Footer />
</NativeRouter>
In my Home Component when a link is clicked About component must render & the Footer must hide & for the rest of the routes Footer must render. Footer is a stateless component.
I have tried accessing props.location in my Footer component but its undefined since props is an empty object {}
My question how to blacklist only one path for not rendering a specific component?
You can use
withRouterto accessprops.locationin yourFooter. Just wrap the return value withwithRouter, and you will get the same props as the other components that you use as Route components.For example, your
Footer.jsshould be like this: