File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed
packages/docusaurus-theme/src/components/theme_context Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change 6
6
useState ,
7
7
} from 'react' ;
8
8
import useIsBrowser from '@docusaurus/useIsBrowser' ;
9
+ import createCache from '@emotion/cache' ;
9
10
import {
10
11
EUI_THEME ,
11
12
EuiProvider ,
@@ -49,9 +50,14 @@ const defaultState: AppThemeContextData = {
49
50
changeTheme : ( themeValue : string ) => { } ,
50
51
} ;
51
52
52
- export const AppThemeContext = createContext < AppThemeContextData > (
53
- defaultState ,
54
- ) ;
53
+ /* creating a cache and passing it to EuiProvider ensures that injected
54
+ Emotion style tags dev mode are in an expected order (global css before component css)
55
+ This only applies for @emotion/react css styles, @emotion/css styles are separate */
56
+ const cssCache = createCache ( {
57
+ key : 'website-css' ,
58
+ } ) ;
59
+
60
+ export const AppThemeContext = createContext < AppThemeContextData > ( defaultState ) ;
55
61
56
62
export const useAppTheme : ( ) => AppThemeContextData = ( ) => {
57
63
return useContext ( AppThemeContext ) ;
@@ -113,6 +119,7 @@ export const AppThemeProvider: FunctionComponent<PropsWithChildren> = ({
113
119
colorMode = { colorMode }
114
120
theme = { theme . provider }
115
121
highContrastMode = { highContrastMode }
122
+ cache = { cssCache }
116
123
>
117
124
{ children }
118
125
</ EuiProvider >
You can’t perform that action at this time.
0 commit comments