I need to handle 2 different header in my application:
- Menu
- A simple Bar with title
Firstly I’m thinking by using the local storage to save the menu I want to showUp (localStorage.setItem('menu', 'default’);)
So when I’m in a component who don’t need the menu but just the simple bar I just resetting the localStorage like this : localStorage.setItem('menu', ‘bar’);
But this idea (I know it's not the best) didn’t re-render my header. What should I do to handle this case ?
In my render I have something like this :
render() {
let menu = localStorage.getItem('menu');
return (
<header>
{menu === 'bar' ? <TopBar/> : <MenuBar/>}
</header>
)
}