File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed
src/components/ComponentsProvider Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change 1
- import React from 'react' ;
1
+ import React , { useEffect } from 'react' ;
2
2
import { lazyComponent } from '../../utils/lazyComponent' ;
3
3
import { LazyComponentWithCode } from '../LazyComponent' ;
4
4
import { ComponentsContext } from './ComponentsContext' ;
@@ -14,7 +14,14 @@ export type { ComponentsProviderProps, ComponentsMap };
14
14
15
15
export const ComponentsProvider : React . FC < ComponentsProviderProps > = ( props ) => {
16
16
const { components, children } = props ;
17
- const componentsRef = React . useRef ( components || { } ) ;
17
+ const componentsRef = React . useRef < ComponentsMap > ( { ...components } ) ;
18
+
19
+ useEffect ( ( ) => {
20
+ componentsRef . current = {
21
+ ...components ,
22
+ ...componentsRef . current ,
23
+ } ;
24
+ } , [ components ] ) ;
18
25
19
26
function addComponent ( code : string , val : ComponentInterface ) {
20
27
componentsRef . current [ code ] = val ;
You can’t perform that action at this time.
0 commit comments