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

Unsafe Lifecycle warning in React >= 16.3 #7

Closed
SebastianStamm opened this issue Apr 11, 2018 · 7 comments
Closed

Unsafe Lifecycle warning in React >= 16.3 #7

SebastianStamm opened this issue Apr 11, 2018 · 7 comments
Assignees

Comments

@SebastianStamm
Copy link

React 16.3.0 declares the componentWillReceiveProps lifecycle method as unsafe and shows warnings when using React.StrictMode

@pomle
Copy link
Contributor

pomle commented Aug 8, 2018

Thank you, I will try to find time to fix this!

@mreishus
Copy link

This should fix it.

Remove these lines:

    componentWillReceiveProps(nextProps) {
        this.handleProps(nextProps);
    }

Add these lines:

    componentDidUpdate(prevProps) {
        if (prevProps.enabled != this.props.enabled) {
            this.handleProps(this.props);
        }
    }

@pomle
Copy link
Contributor

pomle commented Aug 22, 2018

@mreishus why don't you just send a PR? 🤣

@pomle pomle self-assigned this Aug 22, 2018
@mreishus
Copy link

sure, I can, give me a sec

@pomle
Copy link
Contributor

pomle commented Aug 22, 2018

@mreishus thanks, I'm already looking into it. Testing it right now.

@mreishus
Copy link

Ok, oops. I didn't make a pull request initially because I was using a customized version of this in my project, which also had different spacing.. but I should have just gone ahead and done it, my bad.

@pomle
Copy link
Contributor

pomle commented Aug 22, 2018

@SebastianStamm, this has been fixed in 0.2.3. Thanks for the report. Sorry for the slow response.

@pomle pomle closed this as completed Aug 22, 2018
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

3 participants