Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

Lifecycle method componentWillReceiveProps is deprecated #95

Closed
nbkhope opened this issue Feb 3, 2019 · 10 comments · Fixed by #103
Closed

Lifecycle method componentWillReceiveProps is deprecated #95

nbkhope opened this issue Feb 3, 2019 · 10 comments · Fixed by #103

Comments

@nbkhope
Copy link

nbkhope commented Feb 3, 2019

Will there be any updates to the package so that it no longer uses the deprecated lifecycle method componentWillReceiveProps?

Ref https://reactjs.org/docs/react-component.html#unsafe_componentwillreceiveprops

connectModal, for example, uses it:

componentWillReceiveProps(nextProps: ConnectModalProps) {

@veeramarni
Copy link

@yesmeck Do you need PR to replace componentWillReceiveProps with componentDidUpdate?

@yesmeck
Copy link
Owner

yesmeck commented Jun 1, 2019

@veeramarni Yes

@codeskills-nl
Copy link

Just run: npx react-codemod rename-unsafe-lifecycles (or rename manually componentWillReceiveProps to UNSAFE_ componentWillReceiveProps)
It will suppress the warning

@codeskills-nl
Copy link

Replace componentWillReceiveProps with:

  componentDidUpdate() {
    const { modal } = this.props;

    if (isUndefined(modal.show)) {
      return this.unmount();
    }

    if (!modal.show) {
      return destroyOnHide ? this.props.destroy(name) : this.hide();
    }

    if (!resolve) {
      this.show();
    }

    if (resolve) {
      const resolveResult = resolve({ props: modal.props });
      if (!isPromise(resolveResult)) {
        return this.show();
      }
      resolveResult.then(() => {
        this.show();
      });
    }
  }

@masaokiba
Copy link

@yesmeck are you fixing this deprecation issue?

@MonteLogic
Copy link

I am interested in this issue as well.

@yesmeck
Copy link
Owner

yesmeck commented Oct 20, 2019 via email

@leo-esaki
Copy link
Contributor

@yesmeck I wanna create a PR but I don't have a permission?

@yesmeck
Copy link
Owner

yesmeck commented Oct 21, 2019

@leo-esaki You need to fork this repo before creating a PR.

@yesmeck
Copy link
Owner

yesmeck commented Oct 22, 2019

Released 4.0.0

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants