Skip to content

Commit

Permalink
fix #380: use shouldComponentUpdate instead of `UNSAFE_componentWil…
Browse files Browse the repository at this point in the history
…lReceiveProps` (#413)
  • Loading branch information
fostyfost authored Sep 1, 2021
1 parent 0214f84 commit 2bb8887
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions packages/wrapper/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -181,19 +181,15 @@ export const createWrapper = <S extends Store>(makeStore: MakeStore<S>, 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<any>, nextState: Readonly<any>, nextContext: any): boolean {
if (
nextProps?.pageProps?.initialState !== this.props?.pageProps?.initialState ||
nextProps?.initialState !== this.props?.initialState
) {
this.hydrate(nextProps, nextContext);
}

return true;
}

render() {
Expand Down

0 comments on commit 2bb8887

Please sign in to comment.