Answer the question
In order to leave comments, you need to log in
React Router how to hide a component?
I'm still new to react and I have a question.
There is always a navigation component on the page, and there is a component of some page of the site, depending on the route. The
question is, for example, when the authorization page component is on the route, hide the navigation component?
Answer the question
In order to leave comments, you need to log in
In theory.
Start a reducer, write a variable there, like isShow: false, do an action, and when initiating a component, check with an action, you can manipulate the display, you will get isShow from the store, when you call the action and pass the display status to it, React will re-render the component itself {this.props.isShown && <Auth />}
!this.props.router.isActive('/login') && <Menu/>
the component needs to be decorated with withRouter()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question