1
- import React , { useState , useEffect , useMemo } from "react" ;
1
+ import React , { useMemo } from "react" ;
2
2
import { usePluginData } from "@docusaurus/useGlobalData" ;
3
- import ldClient from "launchdarkly" ;
4
3
import { useLocation } from "@docusaurus/router" ;
5
4
import Layout from "@theme-original/Layout" ;
6
5
import ParserOpenRPC from "@site/src/components/ParserOpenRPC" ;
7
6
import { ResponseItem , NETWORK_NAMES } from "@site/src/plugins/plugin-json-rpc" ;
8
7
import styles from "./styles.module.css" ;
9
8
10
- const REF_FF = "mm-new-reference-enabled" ;
11
9
const REF_PATH = "/wallet/reference/" ;
12
10
13
11
export default function LayoutWrapper ( { children } ) {
14
12
const location = useLocation ( ) ;
15
13
const { netData } = usePluginData ( "plugin-json-rpc" ) as {
16
14
netData ?: ResponseItem [ ] ;
17
15
} ;
18
- const [ ldReady , setLdReady ] = useState ( false ) ;
19
- const [ newReferenceEnabled , setNewReferenceEnabled ] = useState ( false ) ;
20
16
21
17
const metamaskNetwork = netData ?. find (
22
18
( net ) => net . name === NETWORK_NAMES . metamask
@@ -37,53 +33,27 @@ export default function LayoutWrapper({ children }) {
37
33
return false ;
38
34
} , [ location . pathname , metamaskMethods ] ) ;
39
35
40
- useEffect ( ( ) => {
41
- ldClient . waitUntilReady ( ) . then ( ( ) => {
42
- setNewReferenceEnabled ( ldClient . variation ( REF_FF , false ) ) ;
43
- setLdReady ( true ) ;
44
- } ) ;
45
- const handleChange = ( current ) => {
46
- setNewReferenceEnabled ( current ) ;
47
- } ;
48
- ldClient . on ( `change:${ REF_FF } ` , handleChange ) ;
49
- return ( ) => {
50
- ldClient . off ( `change:${ REF_FF } ` , handleChange ) ;
51
- } ;
52
- } , [ ] ) ;
53
-
54
- if ( ! referencePageName ) {
55
- return (
56
- < Layout > { children } </ Layout >
57
- )
58
- }
59
-
60
36
return (
61
37
< >
62
38
{
63
- ! ldReady ? null : (
64
- < >
65
- {
66
- newReferenceEnabled ? (
67
- < Layout >
68
- < div className = { styles . pageWrapper } >
69
- { children ?. props ?. children [ 0 ] ?. type === "aside" && (
70
- < > { children . props . children [ 0 ] } </ >
71
- ) }
72
- < div className = { styles . mainContainer } >
73
- < div className = { styles . contentWrapper } >
74
- < ParserOpenRPC
75
- network = { NETWORK_NAMES . metamask }
76
- method = { referencePageName }
77
- />
78
- </ div >
79
- </ div >
80
- </ div >
81
- </ Layout >
82
- ) : (
83
- < Layout > { children } </ Layout >
84
- )
85
- }
86
- </ >
39
+ referencePageName ? (
40
+ < Layout >
41
+ < div className = { styles . pageWrapper } >
42
+ { children ?. props ?. children [ 0 ] ?. type === "aside" && (
43
+ < > { children . props . children [ 0 ] } </ >
44
+ ) }
45
+ < div className = { styles . mainContainer } >
46
+ < div className = { styles . contentWrapper } >
47
+ < ParserOpenRPC
48
+ network = { NETWORK_NAMES . metamask }
49
+ method = { referencePageName }
50
+ />
51
+ </ div >
52
+ </ div >
53
+ </ div >
54
+ </ Layout >
55
+ ) : (
56
+ < Layout > { children } </ Layout >
87
57
)
88
58
}
89
59
</ >
0 commit comments