This repository was archived by the owner on Mar 13, 2025. It is now read-only.
File tree 5 files changed +55
-4
lines changed
5 files changed +55
-4
lines changed Original file line number Diff line number Diff line change
1
+ 10.22.1
Original file line number Diff line number Diff line change @@ -4,4 +4,6 @@ module.exports = {
4
4
setAppMenu : ( ) => { } ,
5
5
getAuthUserTokens : ( ) => new Promise ( ( ) => { } ) ,
6
6
getAuthUserProfile : ( ) => new Promise ( ( ) => { } ) ,
7
+ disableSidebarForRoute : ( ) => { } ,
8
+ enableSidebarForRoute : ( ) => { } ,
7
9
} ;
Original file line number Diff line number Diff line change
1
+ /**
2
+ * This component demonstrates how we can disable sidebar for some subroutes.
3
+ *
4
+ * For example this component disables sidebar for routes "/micro-frontends-react-route/no-sidebar/*".
5
+ */
6
+ import React , { useLayoutEffect } from "react" ;
7
+ import {
8
+ disableSidebarForRoute ,
9
+ enableSidebarForRoute ,
10
+ } from "@topcoder/micro-frontends-navbar-app" ;
11
+
12
+ const COMPONENT_ROUTE = "/micro-frontends-react-route/no-sidebar/*" ;
13
+
14
+ const NoSidebarDemo = ( ) => {
15
+ // use "useLayoutEffect" to remove the sidebar as early as possible
16
+ // without waiting the component to be rendered
17
+ useLayoutEffect ( ( ) => {
18
+ disableSidebarForRoute ( COMPONENT_ROUTE ) ;
19
+ } , [ ] ) ;
20
+
21
+ return (
22
+ < >
23
+ < h2 > Sidebar</ h2 >
24
+ < div > Enable/disable sidebar for routes that match:</ div >
25
+ < pre > { COMPONENT_ROUTE } </ pre >
26
+ < div >
27
+ < button onClick = { ( ) => enableSidebarForRoute ( COMPONENT_ROUTE ) } >
28
+ Enable
29
+ </ button >
30
+ < button onClick = { ( ) => disableSidebarForRoute ( COMPONENT_ROUTE ) } >
31
+ Disable
32
+ </ button >
33
+ </ div >
34
+ </ >
35
+ ) ;
36
+ } ;
37
+
38
+ export default NoSidebarDemo ;
Original file line number Diff line number Diff line change @@ -14,8 +14,14 @@ const appMenu = [
14
14
activeIcon : reactActiveIcon ,
15
15
} ,
16
16
{
17
- title : "Home" ,
18
- path : "/micro-frontends-react-route/home" ,
17
+ title : "Auth Demo" ,
18
+ path : "/micro-frontends-react-route/auth" ,
19
+ icon : homeIcon ,
20
+ activeIcon : homeActiveIcon ,
21
+ } ,
22
+ {
23
+ title : "No Sidebar Demo" ,
24
+ path : "/micro-frontends-react-route/no-sidebar" ,
19
25
icon : homeIcon ,
20
26
activeIcon : homeActiveIcon ,
21
27
} ,
Original file line number Diff line number Diff line change 1
1
import React , { useEffect } from "react" ;
2
- import { Link } from "@reach/router" ;
2
+ import { Link , Router } from "@reach/router" ;
3
3
import { setAppMenu } from "@topcoder/micro-frontends-navbar-app" ;
4
4
import appMenu from "./constants/appMenu" ;
5
5
import AuthDemo from "./components/AuthDemo" ;
6
+ import NoSidebarDemo from "./components/NoSidebarDemo" ;
6
7
7
8
export default function Root ( ) {
8
9
useEffect ( ( ) => {
@@ -32,7 +33,10 @@ export default function Root() {
32
33
</ Link >
33
34
</ div >
34
35
35
- < AuthDemo />
36
+ < Router >
37
+ < AuthDemo path = "/micro-frontends-react-route/auth" />
38
+ < NoSidebarDemo path = "/micro-frontends-react-route/no-sidebar" />
39
+ </ Router >
36
40
</ div >
37
41
) ;
38
42
}
You can’t perform that action at this time.
0 commit comments