From 2bb888775a9a6d6edd8077109de99850ef5655af Mon Sep 17 00:00:00 2001 From: Fosty Fost Date: Thu, 2 Sep 2021 02:08:27 +0300 Subject: [PATCH] fix #380: use `shouldComponentUpdate` instead of `UNSAFE_componentWillReceiveProps` (#413) --- packages/wrapper/src/index.tsx | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/packages/wrapper/src/index.tsx b/packages/wrapper/src/index.tsx index 07303b5..74258fd 100644 --- a/packages/wrapper/src/index.tsx +++ b/packages/wrapper/src/index.tsx @@ -181,19 +181,15 @@ export const createWrapper = (makeStore: MakeStore, config: } as any); } - /** - * If someone knows a better way to replace this with sync hook that can dispatch before render let me know - * @param nextProps - * @param nextContext - * @constructor - */ - UNSAFE_componentWillReceiveProps(nextProps: any, nextContext: any) { + shouldComponentUpdate(nextProps: Readonly, nextState: Readonly, nextContext: any): boolean { if ( nextProps?.pageProps?.initialState !== this.props?.pageProps?.initialState || nextProps?.initialState !== this.props?.initialState ) { this.hydrate(nextProps, nextContext); } + + return true; } render() {