Skip to content
This repository has been archived by the owner on Nov 24, 2023. It is now read-only.

Warning: componentWillMount, componentWillReceiveProps (React 16.x) #44

Open
drichar opened this issue Feb 4, 2020 · 1 comment
Open

Comments

@drichar
Copy link

drichar commented Feb 4, 2020

I'm on React 16.12, and seeing the following warning

Warning: componentWillMount has been renamed, and is not recommended for use. See https://fb.me/react-unsafe-component-lifecycles for details.
      
      * Move code with side effects to componentDidMount, and set initial state in the constructor.
      * Rename componentWillMount to UNSAFE_componentWillMount 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: styled.div, styled.img

(also a similar warning for componentWillReceiveProps)

It's originating from styled-components, which still uses these lifecycle methods in v3: https://github.com/Secretmapper/react-image-annotation/blob/master/package.json#L24

Upgrading to v4/v5 should fix this for anyone using react-image-annotation in React 16.9+ projects. Eventually, in React 17 it simply will not work.

@drichar drichar changed the title Warning: componentWillMount/componentWillReceiveProps (React 16.x) Warning: componentWillMount, componentWillReceiveProps (React 16.x) Feb 4, 2020
@joelpoloney
Copy link

+1 also running into this problem. Are you open to receiving a PR to fix this?

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

No branches or pull requests

2 participants