gg-editor
Version:
A visual graph editor based on G6 and React
19 lines (15 loc) • 548 B
JavaScript
import React from 'react';
import GGEditorContext from '@common/context/GGEditorContext';
export default function (WrappedComponent) {
class InjectGGEditorContext extends React.Component {
render() {
const { forwardRef, ...rest } = this.props;
return (
<GGEditorContext.Consumer>
{context => <WrappedComponent ref={forwardRef} {...rest} {...context} />}
</GGEditorContext.Consumer>
);
}
}
return React.forwardRef((props, ref) => <InjectGGEditorContext {...props} forwardRef={ref} />);
}