withGGEditorContext.js 548 B

123456789101112131415161718
  1. import React from 'react';
  2. import GGEditorContext from '@common/context/GGEditorContext';
  3. export default function (WrappedComponent) {
  4. class InjectGGEditorContext extends React.Component {
  5. render() {
  6. const { forwardRef, ...rest } = this.props;
  7. return (
  8. <GGEditorContext.Consumer>
  9. {context => <WrappedComponent ref={forwardRef} {...rest} {...context} />}
  10. </GGEditorContext.Consumer>
  11. );
  12. }
  13. }
  14. return React.forwardRef((props, ref) => <InjectGGEditorContext {...props} forwardRef={ref} />);
  15. }