#Want the same navbar across my website.

3 messages · Page 1 of 1 (latest)

vague vine
#

I created a website with many pages with react routers. So I want the navbar to be seen everywhere on the website. I've created a separate navbar component and i'm using it in the home page. And in the home page I have some functions which generate some information and that information is passed in the navbar as props.

So my navbar on the home page has that information, I'm not able to do the same for the nabar for other pages like the about page.

Because the information is in the home page not in the about page

tawny void
#

You need to lift up your component state from the Home page 1 level up then you could pass down the relevant information into other components, but in your case you probably want to use e context provider or other state manager.

cobalt prism
#

I agree with @tawny void here. When you have a piece of state that needs to go to lots of different components throughout the app, you should be using useContext to do it.