Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warning Warning: componentWillReceiveProps has been renamed, and is not recommended for use #634

Closed
cardimajs opened this issue Aug 12, 2019 · 9 comments

Comments

@cardimajs
Copy link

I,m using last stable version and get this warning.

react-dom.development.js:12050 Warning: componentWillReceiveProps has been renamed, and is not recommended for use. See https://fb.me/react-async-component-lifecycle-hooks for details.

  • Move data fetching code or side effects to componentDidUpdate.
  • If you're updating state whenever props change, refactor your code to use memoization techniques or move it to static getDerivedStateFromProps. Learn more at: https://fb.me/react-derived-state
  • Rename componentWillReceiveProps to UNSAFE_componentWillReceiveProps to suppress this warning in non-strict mode. In React 17.x, only the UNSAFE_ name will work. To rename all deprecated lifecycles to their new names, you can run npx react-codemod rename-unsafe-lifecycles in your project source folder.

Please update the following components: ColorPicker, EditableInput

@glenn-p-ryan
Copy link

I've left a similar comment on the issue:
#458 (comment)

@hlodver
Copy link

hlodver commented Sep 3, 2019

If you are impatient like me you can use patch-package. It is much easier than forking etc.

The patch file I am using is here:
https://gist.github.com/hlodver/ee336b071f2b2b85c4903660fb8cd686

@cfed
Copy link

cfed commented Sep 12, 2019

Thanks @hlodver for sharing patch-package. It's exactly what I need.

@jasonrobson
Copy link

I am also waiting for this :v, is there any clue about when they are going to update it?

@CyanoFresh
Copy link

same problem

@mikkpokk
Copy link

mikkpokk commented Nov 11, 2019

Problem occurs on this file also: https://github.com/casesandberg/react-color/blob/master/src/components/common/ColorWrap.js

One possible approach:

...
import isEqual from 'lodash/isEqual';
...

export const ColorWrap = (Picker) => {
    class ColorPicker extends (PureComponent || Component) {
        ...
     
        componentDidUpdate(prevProps, prevState) {
            if (! isEqual(this.props, prevProps))
                this.setState({
                    ...color.toState(this.props.color, this.state.oldHue)
                });
        }

        ...
    }
    ...
}

@Snazzie
Copy link

Snazzie commented Jan 8, 2020

Has this project been abandoned?

@casesandberg
Copy link
Owner

This was fixed with #662 and will be released shortly as react-color@2.18.0

@gonzofish
Copy link

Thanks @casesandberg

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

No branches or pull requests

10 participants