Docs >Adding Dependencies
Adding dependencies
If you want the navBar to be closed whenever a state changes you need to pass an array to the prop closeDependency. In this example we used usePathname() from next/navigation, but you can use react-router-dom or any navigation library.
1'use client'
2
3import { usePathname } from 'next/navigation'
4
5export function SideBar () {
6 const pathname = usePathname()
7
8 return (
9 <SideBarContainer closeDependency={[pathname]}>
10 <SideBar
11 buttonContent={'abrir'}
12 navClass='bg-[#15181c] w-48 relative'
13 >
14 </SideBar>
15 </SideBarContainer>
16 )
17}
In the other hand if you want the navBar to be opened whenever a state changes you need to pass an array to the prop openDependency. In this case we used a shopping cart as an example.
1export function SideBar ({ shoppingCart }) {
2 return (
3 <SideBarContainer openDependency={[shoppingCart]}>
4 <SideBar
5 buttonContent={'abrir'}
6 navClass='bg-[#15181c] w-48'
7 >
8 </SideBar>
9 </SideBarContainer>
10 )
11}