1
1
import type { Plugin } from '@plexinc/react-lightning' ;
2
- import { StyleSheet } from 'react-native-web' ;
3
2
// Necessary for the declaration merging to work below, since we don't import
4
3
// the `react-native-web` typings.
5
4
import '../types/react-native-web.d.ts' ;
@@ -15,9 +14,13 @@ function camelize(text: string) {
15
14
}
16
15
17
16
export const cssClassNameTransformPlugin = ( ) : Plugin => {
18
- const sheet = new CSSStyleSheet ( ) ;
17
+ const sheet = Array . from ( document . styleSheets ) . find ( ( s ) => {
18
+ const node = s . ownerNode ;
19
+
20
+ return node && 'id' in node ? node . id === 'react-native-stylesheet' : null ;
21
+ } ) ?? { cssRules : [ ] } ;
22
+
19
23
const cache : Record < string , Record < string , string > > = { } ;
20
- let currentCssText = '' ;
21
24
22
25
function parseStyle ( cssText : string ) {
23
26
if ( ! cache [ cssText ] ) {
@@ -43,13 +46,6 @@ export const cssClassNameTransformPlugin = (): Plugin => {
43
46
return props ;
44
47
}
45
48
46
- const newCssText = StyleSheet . getSheet ( ) . textContent ;
47
-
48
- if ( newCssText !== currentCssText ) {
49
- sheet . replaceSync ( newCssText ) ;
50
- currentCssText = newCssText ;
51
- }
52
-
53
49
const { className, style, ...otherProps } = props ;
54
50
let finalStyle : typeof style = { } ;
55
51
0 commit comments