Commit 8c6cae22 authored by Shen Chang's avatar Shen Chang Committed by GitHub

fix(keepAlive): Fixing multiple higher-order functions to get no real components

parent 435d90d4
......@@ -55,6 +55,14 @@ export default function keepAliveDecorator({
forwardRef = false,
}: IOptions = {}) {
return (Component: React.ComponentType<IComponentProps>) => {
const {
WrappedComponent,
wrappedComponent,
} = Component;
if (WrappedComponent || wrappedComponent) {
Component = WrappedComponent || wrappedComponent;
}
const {
componentDidMount = noop,
componentDidUpdate = noop,
......@@ -334,8 +342,6 @@ export default function keepAliveDecorator({
}
class ListenUpperKeepAliveContainer extends React.Component<IListenUpperKeepAliveContainerProps, IListenUpperKeepAliveContainerState> {
public static displayName = `${keepAliveDisplayName}(${displayName})`;
private combinedKeepAlive: boolean;
public state = {
......@@ -459,15 +465,18 @@ export default function keepAliveDecorator({
withIdentificationContextConsumer(ListenUpperKeepAliveContainer)
);
let NewComponent: React.ComponentType<IKeepAliveDecorativeComponentProps> = ListenUpperKeepAliveContainerHOC;
let KeepAlive: React.ComponentType<IKeepAliveDecorativeComponentProps> = ListenUpperKeepAliveContainerHOC;
if (forwardRef) {
NewComponent = React.forwardRef((props, ref) => (
KeepAlive = React.forwardRef((props, ref) => (
<ListenUpperKeepAliveContainerHOC
{...props}
forwardedRef={ref}
/>
));
}
return hoistNonReactStatics(NewComponent, Component);
KeepAlive.WrappedComponent = Component;
KeepAlive.displayName = `${keepAliveDisplayName}(${displayName})`;
return hoistNonReactStatics(KeepAlive, 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