File tree Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Original file line number Diff line number Diff line change
1
+ import { useRef } from "react" ;
1
2
import { Link } from "react-router" ;
2
3
import { IconBars3 } from "." ;
3
4
4
5
export function Header ( ) {
6
+ const drawerRef = useRef < HTMLInputElement > ( null ) ;
7
+
8
+ const closeDrawer = ( ) => {
9
+ if ( drawerRef . current ) {
10
+ drawerRef . current . checked = false ;
11
+ }
12
+ } ;
13
+
5
14
// https://v5.daisyui.com/components/drawer/#drawer-that-opens-from-right-side-of-page
6
15
const SideBar = ( ) => (
7
16
< div className = "drawer" >
8
- < input id = "my-drawer" type = "checkbox" className = "drawer-toggle" />
17
+ < input
18
+ id = "my-drawer"
19
+ type = "checkbox"
20
+ className = "drawer-toggle"
21
+ ref = { drawerRef }
22
+ />
9
23
< div className = "drawer-content" >
10
24
< label
11
25
htmlFor = "my-drawer"
@@ -23,7 +37,9 @@ export function Header() {
23
37
> </ label >
24
38
< ul className = "menu bg-base-200 text-base-content min-h-full w-40 p-4" >
25
39
< li >
26
- < Link to = "/" > Networks</ Link >
40
+ < Link to = "/" onClick = { closeDrawer } >
41
+ Networks
42
+ </ Link >
27
43
</ li >
28
44
</ ul >
29
45
</ div >
You can’t perform that action at this time.
0 commit comments