* For rendering components that are out of the regular layout tree.
({component, componentPath, temp = false}: Props)
| 20 | * For rendering components that are out of the regular layout tree. |
| 21 | */ |
| 22 | function ExternalWrapper({component, componentPath, temp = false}: Props) { |
| 23 | const dispatch: any = useDispatch(); |
| 24 | const [inserted, setInserted] = useState(false); |
| 25 | |
| 26 | useEffect(() => { |
| 27 | // Give empty props for the inserted components. |
| 28 | // The props will come from the parent so they can be updated. |
| 29 | dispatch( |
| 30 | addComponentToLayout({ |
| 31 | component, |
| 32 | componentPath |
| 33 | }) |
| 34 | ); |
| 35 | setInserted(true); |
| 36 | return () => { |
| 37 | if (temp) { |
| 38 | dispatch(removeComponent({componentPath})); |
| 39 | } |
| 40 | }; |
| 41 | }, []); |
| 42 | |
| 43 | useEffect(() => { |
| 44 | batch(() => { |
| 45 | dispatch( |
| 46 | updateProps({itempath: componentPath, props: component.props}) |
| 47 | ); |
| 48 | if (component.props.id) { |
| 49 | dispatch( |
| 50 | notifyObservers({ |
| 51 | id: component.props.id, |
| 52 | props: component.props |
| 53 | }) |
| 54 | ); |
| 55 | } |
| 56 | }); |
| 57 | }, [component.props]); |
| 58 | |
| 59 | if (!inserted) { |
| 60 | return null; |
| 61 | } |
| 62 | // Render a wrapper with the actual props. |
| 63 | return <DashWrapper componentPath={componentPath} />; |
| 64 | } |
| 65 | export default ExternalWrapper; |
nothing calls this directly
no test coverage detected
searching dependent graphs…