Secretmapper / react-image-annotation

An infinitely customizable image annotation library built on React
https://secretmapper.github.io/react-image-annotation/
MIT License
324 stars 135 forks source link

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

Open drichar opened 4 years ago

drichar commented 4 years ago

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.

joelpoloney commented 3 years ago

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