Skip to content

Commit 2bb8887

Browse files
authored
fix #380: use shouldComponentUpdate instead of UNSAFE_componentWillReceiveProps (#413)
1 parent 0214f84 commit 2bb8887

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

packages/wrapper/src/index.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -181,19 +181,15 @@ export const createWrapper = <S extends Store>(makeStore: MakeStore<S>, config:
181181
} as any);
182182
}
183183

184-
/**
185-
* If someone knows a better way to replace this with sync hook that can dispatch before render let me know
186-
* @param nextProps
187-
* @param nextContext
188-
* @constructor
189-
*/
190-
UNSAFE_componentWillReceiveProps(nextProps: any, nextContext: any) {
184+
shouldComponentUpdate(nextProps: Readonly<any>, nextState: Readonly<any>, nextContext: any): boolean {
191185
if (
192186
nextProps?.pageProps?.initialState !== this.props?.pageProps?.initialState ||
193187
nextProps?.initialState !== this.props?.initialState
194188
) {
195189
this.hydrate(nextProps, nextContext);
196190
}
191+
192+
return true;
197193
}
198194

199195
render() {

0 commit comments

Comments
 (0)