Skip to content
Snippets Groups Projects
Commit dbedbed8 authored by Chris Beer's avatar Chris Beer
Browse files

Allow plugin components to be react elements

parent 412b8f63
No related branches found
No related tags found
No related merge requests found
...@@ -61,7 +61,7 @@ ...@@ -61,7 +61,7 @@
config: { config: {
foo: 'bar', foo: 'bar',
}, },
component: AddPluginComponentA, component: <AddPluginComponentA />,
}; };
const addPluginB = { const addPluginB = {
......
...@@ -6,11 +6,15 @@ export const PluginHook = React.forwardRef((props, ref) => { ...@@ -6,11 +6,15 @@ export const PluginHook = React.forwardRef((props, ref) => {
const { classes, ...otherProps } = props; // eslint-disable-line react/prop-types const { classes, ...otherProps } = props; // eslint-disable-line react/prop-types
return PluginComponents ? ( return PluginComponents ? (
PluginComponents.map((PluginComponent, index) => ( // eslint-disable-line react/prop-types PluginComponents.map((PluginComponent, index) => ( // eslint-disable-line react/prop-types
React.isValidElement(PluginComponent)
? React.cloneElement(PluginComponent, { ...otherProps, ref })
: (
<PluginComponent <PluginComponent
ref={ref} ref={ref}
{...otherProps} {...otherProps}
key={index} // eslint-disable-line react/no-array-index-key key={index} // eslint-disable-line react/no-array-index-key
/> />
)
)) ))
) : null; ) : null;
}); });
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment