React-virtualized: createClass & Proptypes warnings with React 15.5

Created on 5 Mar 2018  Â·  16Comments  Â·  Source: bvaughn/react-virtualized

In react 15.5 the browser console and test results get polluted with the following warnings. The call stack in the logs says it is the react-virtualised import/require call that is triggering the warnings.

Warning: Accessing PropTypes via the main React package is deprecated, and will be removed in  React v16.0. Use the latest available v15.* prop-types package from npm instead. For info on usage, compatibility, migration and more, see https://fb.me/prop-types-docs
Warning: Accessing createClass via the main React package is deprecated, and will be removed in React v16.0. Use a plain JavaScript class instead. If you're not yet ready to migrate, create-react-class v15.* is available on npm as a temporary, drop-in replacement. For more info see https://fb.me/react-create-class

Minor issue I know but hopefully an easy fix?

All 16 comments

Yep. The fix is simple. Import stuff from this packages
https://www.npmjs.com/package/create-react-class
https://www.npmjs.com/package/prop-types

Do you have propTypes and createClass in rows/cells? Or do you use typescript?

My theory is it is the import * as React from 'react'; in a couple of react-virtualized files that is causing the console errors. I assume the react deprecation warnings are dumb and any imports, even unused ones are flagged.

This code pen exhibits the behaviour we are seeing: https://codepen.io/anon/pen/zRVNaQ

To be clear we do not import propTypes or createClass from React in any of our project's files.

I can try to fix this issue by submitting a PR. Shall I work on this?

@hartror You probably need to update react.

Would you accept a fixing PR for this?

@hartror have you seen https://github.com/facebook/flow/issues/4673 ? - im not sure that a PR would do the trick here (but if you have something in mind, id be keen on seeing it). We're making use of this gist to work around it for the time being.

And as @TrySound said, you could also go for react 16

I thought we could just replace the import * as React from 'react'; with more specific imports? None of our own files generate this error.

Yeah, should be doable. See the note just _above_ https://flow.org/en/docs/react/types/#toc-react-node for some more info.

Since react 15 causes only warnings and do not break your application I don't think we should change virtualized code and a lot of projects who use the same way to import react.

I'm disappointed but accept that it is your decision to make. Thanks for your time and a great package.

I agree with @hartror that we need to remove import * from React and use explicit imports so that other projects using react-virtualized can _confidently_ upgrade to React 16.

@theTechie They can. There's just a noise in console in dev mode. It's not the end of the world. Or do you suggest to upgrade dozens of projects who uses the same way and still supports react 15?

I understand it's just a noise. Its just that I will not be very confident
upgrading my app to React 16 having 'react-virtualized' still making a get
to creatClass or propTypes. Even though we are not using any of these in
the codebase, there is no guarantee it will not be in the future. Isn't it ?

Let me ask this question in a different way; Is 'react-virtualized'
compatible with React 16 ? The answer might be Yes today. But, there is no
guarantee since we can still write code referring to createClass /
propTypes which just breaks on React 16.

Correct me if I am missing something here.

On Thu, 24 May 2018 at 5:07 PM, Bogdan Chadkin notifications@github.com
wrote:

@theTechie https://github.com/theTechie They can. There's just a noise
in console in dev mode. It's not the end of the world. Or do you suggest
to upgrade dozens of projects who uses the same way and still supports
react 15?

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/bvaughn/react-virtualized/issues/1037#issuecomment-391682781,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AA_31gyM6ONY12ApRNjalPx7yJxDo13uks5t1ptsgaJpZM4SbuGc
.

>

Regards,
Gagan

React virtualized is compatible with react 16. You should never use propTypes and createClass from react namespace. If one of your dependencies uses them then send issue or replace with maintaned dependency.

Was this page helpful?
0 / 5 - 0 ratings