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

Stop using componentWillMount #644

Closed
luisherranz opened this issue May 7, 2018 · 4 comments
Closed

Stop using componentWillMount #644

luisherranz opened this issue May 7, 2018 · 4 comments
Assignees
Labels

Comments

@luisherranz
Copy link

  • emotion version: 9.1.3
  • react version: 16.3

Relevant code.

        componentWillMount() {
          if (this.context[channel] !== undefined) {
            this.unsubscribe = this.context[channel].subscribe(
              setTheme.bind(this)
            )
          }
        }

What you did:
Update to React 16.3 and use strict mode.

What happened:
This warning appeared: componentWillMount: Please update the following components to use componentDidMount instead: Styled(div), Styled(li), Styled(span), Styled(ul)

Reproduction:
Just use styled within React strict-mode or React Async:
https://codesandbox.io/s/732mw5w53j

Problem description:
componentWillMount is going to be deprecated and should be avoided from now on.

Suggested solution:
This is the componentWillMount which is causing the warning:
https://github.com/emotion-js/emotion/blob/82fd71a8f9fda7df31b4810b17a255a75500686b/packages/create-emotion-styled/src/index.js

That logic could be moved to the componentDidMount or the constructor. Whichever is the case, let me know and I'll do a PR.

@stale
Copy link

stale bot commented Aug 29, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.

@splitcircle
Copy link

made PR #830 to fix this

@emmatown
Copy link
Member

As I mentioned in #830, this is going to be fixed in emotion 10.

@FezVrasta
Copy link
Member

Closing as fixed by Emotion 10

facebook-github-bot pushed a commit to facebook/flipper that referenced this issue Dec 11, 2019
Summary: React 16 is not compatible with react-emotion 9 (it prints warnings, see also emotion-js/emotion#644). So we should upgrade to 10.

Reviewed By: mweststrate

Differential Revision: D18905889

fbshipit-source-id: c00d2dbbadb1c08544632cb9bfcd63f2b1818a25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants