1010
1111import { PREFIXCLS , THEME_CONFIG } from '@_lib/AntdThemeConfig' ;
1212import { makeStore , AppStore } from '@_store' ;
13+ import type { ICMSChartImageConfig } from '@_api/fetchCMS' ;
1314// import { wrapper } from '@_store';
14- import { createContext , useContext , useEffect , useMemo , useRef , useState } from 'react' ;
15+ import { createContext , useContext , useRef } from 'react' ;
1516import { AELFDProvider } from 'aelf-design' ;
1617import 'aelf-design/css' ;
1718import { ConfigProvider } from 'antd' ;
1819import { Provider as ReduxProvider } from 'react-redux' ;
19- import useResponsive from '@_hooks/useResponsive' ;
20- import dynamic from 'next/dynamic' ;
2120import WebLoginProvider from './webLoginProvider' ;
2221// const OpentelemetryProvider = dynamic(
2322// () => import('./opentelemetryProvider').then((mod) => mod.OpentelemetryProvider),
2423// { ssr: false },
2524// );
2625
27- const MobileContext = createContext < any > ( { } ) ;
26+ interface IMobileContextValue {
27+ isMobileSSR : boolean ;
28+ config : Record < string , any > ;
29+ chartImg ?: ICMSChartImageConfig ;
30+ }
31+
32+ interface IRootProviderProps {
33+ children : React . ReactNode ;
34+ isMobileSSR : boolean ;
35+ config : Record < string , any > ;
36+ chartImg ?: ICMSChartImageConfig ;
37+ networkList : any [ ] ;
38+ headerMenuList : any [ ] ;
39+ chainList : any [ ] ;
40+ }
41+
42+ const MobileContext = createContext < IMobileContextValue > ( {
43+ isMobileSSR : false ,
44+ config : { } ,
45+ } ) ;
2846const HeaderContext = createContext < any > ( { } ) ;
2947
3048const useMobileContext = ( ) => {
@@ -35,18 +53,20 @@ const useHeaderContext = () => {
3553} ;
3654export { useMobileContext , useHeaderContext } ;
3755
38- function RootProvider ( { children, isMobileSSR, config, chartImg, networkList, headerMenuList, chainList } ) {
56+ function RootProvider ( {
57+ children,
58+ isMobileSSR,
59+ config,
60+ chartImg,
61+ networkList,
62+ headerMenuList,
63+ chainList,
64+ } : IRootProviderProps ) {
3965 const storeRef = useRef < AppStore > ( ) ;
4066 if ( ! storeRef . current ) {
4167 storeRef . current = makeStore ( ) ;
4268 }
4369
44- const [ isMobile , setIsMobile ] = useState ( isMobileSSR ) ;
45- const { isMobile : isMobileClient } = useResponsive ( ) ;
46- useEffect ( ( ) => {
47- setIsMobile ( isMobileClient ) ;
48- } , [ isMobileClient ] ) ;
49-
5070 return (
5171 < AELFDProvider prefixCls = { PREFIXCLS } theme = { THEME_CONFIG } >
5272 < ConfigProvider prefixCls = { PREFIXCLS } theme = { THEME_CONFIG } >
0 commit comments