In my Menu component, I have 2 tab like below
<span>
<Link to="inventory"> Inventory</Link>
</span>
<span >
<Link to="user"> Users</Link>
</span>
actually Users I want to display only for users who are admin. so whether user is admin or not I am checking in Admin component.
How can I bring data from Admin on Menu and displayUser tab conditionally?
I know I can wrtie something
{isActive && <Link>} etc
so in my Admin component I am calling API and bringing the data. and checking if particular valus is admin then I am making isActive as true and I need to send it to Menu component.
But I dont know how to bring isActive from Admin into Menu?
Could you please help?
Generally to share a state between all components and refuse prop drilling the best way is use react context or in some cases use redux. https://reactjs.org/docs/context.html ==> react context