0

How to hide header component conditionally wise see in my codesandbox I do not want schedule tab to display header how this possible

Please guide thanks

https://codesandbox.io/s/vvoqvk78

1 Answer 1

1

You could wrap your app with withRouter and access the current location from the location prop. This enables you to render the header conditionally:

  const App = props => (
  <div>
    {props.location.pathname !== "/schedule" && <Header />}
    <Main />
  </div>
);

export default withRouter(App);

Here is a codepen.

Hope this helps. Happy coding.

Sign up to request clarification or add additional context in comments.

2 Comments

Thank @Domino987, Can you please explain what React.Fragment does ?
Here are the docs: They are just an invisible wrapper around your components so that you don't have to wrap them in a div, if you have some components which live side-by-side.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.