rafgraph / react-interactive

Better hover, active and focus states than CSS pseudo-classes, and a callback when the interactive state changes.
https://react-interactive.rafgraph.dev
MIT License
167 stars 8 forks source link

Rename componentWillReceiveProps to UNSAFE_componentWillReceiveProps #10

Closed zarsky-broad closed 5 years ago

zarsky-broad commented 5 years ago

This suppresses a console warning in React 16.9 and will be required for React 17.x.

The console warning:

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: Interactive
rafgraph commented 5 years ago

Thanks for the PR, is the compatible version range for UNSAFE_componentWillReceiveProps React >= 16.3?

zarsky-broad commented 5 years ago

Yup, looks like it: https://reactjs.org/blog/2018/03/27/update-on-async-rendering.html#gradual-migration-path

zarsky-broad commented 5 years ago

@rafrex any chance of merging this in soon? Is there anything I can do to help this move forward? Thanks!

rafgraph commented 5 years ago

Released v0.9.0 with this change.