File tree 3 files changed +9
-4
lines changed
src/components/ThemeProvider
3 files changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -6,15 +6,19 @@ import { useSyncExternalStore } from 'use-sync-external-store/shim/index.js';
6
6
import { StyleStore } from '../stores/StyleStore.js' ;
7
7
import { useIsomorphicLayoutEffect } from './useIsomorphicLayoutEffect.js' ;
8
8
9
- export function useStylesheet ( styles : StyleDataCSP , componentName : string ) {
9
+ interface UseStyleSheetOptions {
10
+ alwaysInject ?: boolean ;
11
+ }
12
+
13
+ export function useStylesheet ( styles : StyleDataCSP , componentName : string , options ?: UseStyleSheetOptions ) {
10
14
const { staticCssInjected, componentsMap } = useSyncExternalStore (
11
15
StyleStore . subscribe ,
12
16
StyleStore . getSnapshot ,
13
17
StyleStore . getServerSnapshot
14
18
) ;
15
19
16
20
useIsomorphicLayoutEffect ( ( ) => {
17
- const shouldInject = ! staticCssInjected ;
21
+ const shouldInject = options ?. alwaysInject || ! staticCssInjected ;
18
22
if ( shouldInject ) {
19
23
createOrUpdateStyle ( styles , 'data-ui5wcr-component' , componentName ) ;
20
24
StyleStore . mountComponent ( componentName ) ;
Original file line number Diff line number Diff line change 41
41
"license" : " Apache-2.0" ,
42
42
"sideEffects" : [
43
43
" ./dist/Assets.js" ,
44
- " ./dist/json-imports/*"
44
+ " ./dist/json-imports/*" ,
45
+ " ./dist/css/index.css"
45
46
],
46
47
"scripts" : {
47
48
"clean" : " rimraf dist tmp wrappers ssr" ,
Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ import { styleData } from './ThemeProvider.css.js';
20
20
function ThemeProviderStyles ( ) {
21
21
const uniqueId = useIsomorphicId ( ) ;
22
22
useStylesheet ( styleData , `${ ThemeProvider . displayName } -${ uniqueId } ` ) ;
23
- useStylesheet ( ui5WcVariablesStyleData , `${ ThemeProvider . displayName } -css-vars-${ uniqueId } ` ) ;
23
+ useStylesheet ( ui5WcVariablesStyleData , `${ ThemeProvider . displayName } -css-vars-${ uniqueId } ` , { alwaysInject : true } ) ;
24
24
return null ;
25
25
}
26
26
You can’t perform that action at this time.
0 commit comments