11import React , { useState , useEffect } from 'react' ;
22import { batch , useDispatch } from 'react-redux' ;
33
4- import { DashLayoutPath } from '../types/component' ;
4+ import { DashComponent , DashLayoutPath } from '../types/component' ;
55import DashWrapper from './DashWrapper' ;
66import {
77 addComponentToLayout ,
@@ -11,21 +11,14 @@ import {
1111} from '../actions' ;
1212
1313type Props = {
14+ component : DashComponent ;
1415 componentPath : DashLayoutPath ;
15- componentType : string ;
16- componentNamespace : string ;
17- [ k : string ] : any ;
1816} ;
1917
2018/**
2119 * For rendering components that are out of the regular layout tree.
2220 */
23- function ExternalWrapper ( {
24- componentType,
25- componentNamespace,
26- componentPath,
27- ...props
28- } : Props ) {
21+ function ExternalWrapper ( { component, componentPath} : Props ) {
2922 const dispatch : any = useDispatch ( ) ;
3023 const [ inserted , setInserted ] = useState ( false ) ;
3124
@@ -34,11 +27,7 @@ function ExternalWrapper({
3427 // The props will come from the parent so they can be updated.
3528 dispatch (
3629 addComponentToLayout ( {
37- component : {
38- type : componentType ,
39- namespace : componentNamespace ,
40- props : props
41- } ,
30+ component,
4231 componentPath
4332 } )
4433 ) ;
@@ -50,12 +39,19 @@ function ExternalWrapper({
5039
5140 useEffect ( ( ) => {
5241 batch ( ( ) => {
53- dispatch ( updateProps ( { itempath : componentPath , props} ) ) ;
54- if ( props . id ) {
55- dispatch ( notifyObservers ( { id : props . id , props} ) ) ;
42+ dispatch (
43+ updateProps ( { itempath : componentPath , props : component . props } )
44+ ) ;
45+ if ( component . props . id ) {
46+ dispatch (
47+ notifyObservers ( {
48+ id : component . props . id ,
49+ props : component . props
50+ } )
51+ ) ;
5652 }
5753 } ) ;
58- } , [ props ] ) ;
54+ } , [ component . props ] ) ;
5955
6056 if ( ! inserted ) {
6157 return null ;
0 commit comments