Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
)
) {
instance.componentDidUpdate(prevProps, state, snapshot);
}
} else if (
lifecycles.componentDidUpdate
&& typeof instance.componentDidUpdate === 'function'
) {
if (lifecycles.componentDidUpdate.prevContext) {
instance.componentDidUpdate(prevProps, state, prevContext);
} else if (!state || shallowEqual(this.instance().state, state)) {
instance.componentDidUpdate(prevProps, state);
}
}
// If it doesn't need to rerender, update only its props.
} else if (!shallowEqual(props, instance.props)) {
instance.props = (Object.freeze || Object)({ ...instance.props, ...props });
}
this.update();
});
});
shouldRender
&& !this[OPTIONS].disableLifecycleMethods
&& instance
) {
privateSetChildContext(adapter, this, instance, node, getChildContextSpy);
if (lifecycles.getSnapshotBeforeUpdate) {
let snapshot;
if (typeof instance.getSnapshotBeforeUpdate === 'function') {
snapshot = instance.getSnapshotBeforeUpdate(prevProps, state);
}
if (
lifecycles.componentDidUpdate
&& typeof instance.componentDidUpdate === 'function'
&& (
!state
|| shallowEqual(state, this.instance().state)
|| typeof type.getDerivedStateFromProps === 'function'
)
) {
instance.componentDidUpdate(prevProps, state, snapshot);
}
} else if (
lifecycles.componentDidUpdate
&& typeof instance.componentDidUpdate === 'function'
) {
if (lifecycles.componentDidUpdate.prevContext) {
instance.componentDidUpdate(prevProps, state, prevContext);
} else if (!state || shallowEqual(this.instance().state, state)) {
instance.componentDidUpdate(prevProps, state);
}
}
// If it doesn't need to rerender, update only its props.
function pureComponentShouldComponentUpdate(prevProps, props, prevState, state) {
return !shallowEqual(prevProps, props) || !shallowEqual(prevState, state);
}
wrappedComponent = function (props, ...args) {
const shouldUpdate = memoized === sentinel || (compare
? !compare(prevProps, props)
: !shallowEqual(prevProps, props)
);
if (shouldUpdate) {
memoized = Component({ ...Component.defaultProps, ...props }, ...args);
prevProps = props;
}
return memoized;
};
}