-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
/
Copy pathExternalComponent.js
41 lines (36 loc) · 1.21 KB
/
ExternalComponent.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import React from 'react';
import PropTypes from 'prop-types';
const ExternalComponent = ({ id, text, input_id, extra_component }) => {
const ctx = window.dash_component_api.useDashContext();
const ExternalWrapper = window.dash_component_api.ExternalWrapper;
return (
<div id={id}>
<ExternalWrapper
id={input_id}
componentType="Input"
componentNamespace="dash_core_components"
value={text}
componentPath={[...ctx.componentPath, 'external']}
/>
{
extra_component &&
<ExternalWrapper
componentType={extra_component.type}
componentNamespace={extra_component.namespace}
componentPath={[...ctx.componentPath, 'extra']}
{...extra_component.props}
/>}
</div>
)
}
ExternalComponent.propTypes = {
id: PropTypes.string,
text: PropTypes.string,
input_id: PropTypes.string,
extra_component: PropTypes.exact({
type: PropTypes.string,
namespace: PropTypes.string,
props: PropTypes.object,
}),
};
export default ExternalComponent;