I have a Meteor
application that I'm developing using React
and I do my routing using FlowRouter
. My main AppContainer
for the project has a bunch of components, one of them being the footer.
class AppContainer extends Component {
render() {
return(
<div className="hold-transition skin-green sidebar-mini">
<div className="wrapper">
<Header user={this.props.user} />
<MainSideBar />
{this.props.content}
<Footer />
<ControlSideBar />
<div className="control-sidebar-bg"></div>
</div>
</div>
)
}
}
I have a few routes that go to various chat rooms:
Eg.
/chatroom/1
/chatroom/2
/chatroom/3
Is there a way for me to hide the <Footer />
component if the route is a /chatroom/<anything>
?
You can maybe do a conditional rendering by checking the current path.
If the
<anything>
part (I assume it is a parameter) after the/chatroom/
is not important, and if you do not have any other routing that starts with chatroom, you can try this one:So your code would look like this:
If
<anything>
part is important and/or you have other routes that starts with chatroom, you can first get the parameter of the route withand then do the conditional rendering by checking if the current path contains the chatroom/:param like this:
So your code would look like this