Commit 1529a7fd authored by Shen Chang's avatar Shen Chang Committed by GitHub

Fixing multiple higher-order functions to get no real components

parent 8c6cae22
......@@ -6,6 +6,14 @@ import withIdentificationContextConsumer from './withIdentificationContextConsum
import getDisplayName from './getDisplayName';
export default function bindLifecycle<P = any>(Component: React.ComponentType<P>) {
const {
WrappedComponent,
wrappedComponent,
} = Component;
if (WrappedComponent || wrappedComponent) {
Component = WrappedComponent || wrappedComponent;
}
const {
componentDidMount = noop,
componentDidUpdate = noop,
......@@ -82,7 +90,7 @@ export default function bindLifecycle<P = any>(Component: React.ComponentType<P>
);
};
const NewComponent = withIdentificationContextConsumer(
const BindLifecycleHOC = withIdentificationContextConsumer(
({
forwardRef,
_identificationContextProps: {
......@@ -109,12 +117,14 @@ export default function bindLifecycle<P = any>(Component: React.ComponentType<P>
: null
),
);
const BindLifecycle = React.forwardRef((props, ref) => (
<BindLifecycleHOC {...props} forwardRef={ref} />
));
NewComponent.displayName = `bindLifecycle(${getDisplayName(Component)})`;
BindLifecycle.WrappedComponent = Component;
BindLifecycle.displayName = `bindLifecycle(${getDisplayName(Component)})`;
return hoistNonReactStatics(
React.forwardRef((props, ref) => (
<NewComponent {...props} forwardRef={ref} />
)),
BindLifecycle,
Component,
);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment