ReactTraining / react-media

CSS media queries for React
MIT License
2.44k stars 115 forks source link

React v16.9 support #134

Closed mikecousins closed 5 years ago

mikecousins commented 5 years ago

componentWillMount is deprecated with warnings now in 16.9.

Here is the warning that is emitted: react-dom.development.js:12050 Warning: componentWillMount has been renamed, and is not recommended for use. See https://fb.me/react-async-component-lifecycle-hooks for details.

Please update the following components: Media

edorivai commented 5 years ago

Please have a look at the next release:

npm install react-media@next
cliffhall commented 5 years ago

1.10.0-alpha.1 works for me. Before, I was getting the following in the console:

react-dom.development.js:12050 Warning: componentWillMount has been renamed, and is not recommended for use. See https://fb.me/react-async-component-lifecycle-hooks for details.

  • Move code with side effects to componentDidMount, and set initial state in the constructor.
  • Rename componentWillMount to UNSAFEcomponentWillMount 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: Media

Now the message is gone. Thanks @edorivai.

msegers commented 5 years ago

@edorivai Hi,

So same as everyone else, why is this release an alpha any issues with the current lib?

edorivai commented 5 years ago

Hi :wave:,

Reason it's an behind the @next flag is because I wanted to make sure some people tested this out in the wild before publishing a minor version bump. Since it's a minor bump, depending on the setup people have they might auto upgrade to this version without realizing. This should be fine, it's a minor upgrade, so it should be backwards compatible, but I wanted to make sure before publishing.

I guess by now enough people have tested it (judging from the :+1:'s in this thread), I'll try to publish this on mainline soon.

msegers commented 5 years ago

Allright, thanks for your time!

edorivai commented 5 years ago

v1.10.0 has been deployed as latest

npm install react-media should now install that version which should take care of any react deprecation warnings :tada: