File tree 2 files changed +8
-6
lines changed
src/components/observableEmbed
2 files changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -37,12 +37,13 @@ const ref = useRef<HTMLDivElement | null>(null);
37
37
38
38
useEffect (() => {
39
39
(async () => {
40
- const target = ref .current ;
41
- if (! target ) return ;
42
- while (target .firstChild ) target .removeChild (target .firstChild );
43
40
const mod = await import (/* webpackIgnore: true */ module );
44
41
const component = mod [importName ];
45
42
const element = component instanceof Function ? await component () : component ;
43
+
44
+ const target = ref .current ;
45
+ if (! target ) return ;
46
+ while (target .firstChild ) target .removeChild (target .firstChild );
46
47
target .append (element );
47
48
})();
48
49
}, [importName , module ]);
Original file line number Diff line number Diff line change @@ -14,12 +14,13 @@ export const ObservableEmbedClient: React.FC<ObservableEmbedProps> = ({
14
14
15
15
useEffect ( ( ) => {
16
16
( async ( ) => {
17
- const target = ref . current ;
18
- if ( ! target ) return ;
19
- while ( target . firstChild ) target . removeChild ( target . firstChild ) ;
20
17
const mod = await import ( /* webpackIgnore: true */ module ) ;
21
18
const component = mod [ importName ] ;
22
19
const element = component instanceof Function ? await component ( ) : component ;
20
+
21
+ const target = ref . current ;
22
+ if ( ! target ) return ;
23
+ while ( target . firstChild ) target . removeChild ( target . firstChild ) ;
23
24
target . append ( element ) ;
24
25
} ) ( ) ;
25
26
} , [ importName , module ] ) ;
You can’t perform that action at this time.
0 commit comments