Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PropTypes & createClass warnings echo when using import * as React #10583

Closed
STRML opened this issue Aug 31, 2017 · 6 comments
Closed

PropTypes & createClass warnings echo when using import * as React #10583

STRML opened this issue Aug 31, 2017 · 6 comments

Comments

@STRML
Copy link
Contributor

STRML commented Aug 31, 2017

Do you want to request a feature or report a bug?

This is a bug.

What is the current behavior?

This simple script:

import * as React from 'react';

throws the following warnings:

$ ./node_modules/.bin/babel-node foo.js                                                                                                                                                                   15:00:58
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

What is the expected behavior?

I expect these deprecation warnings not to throw. The import * as React syntax is now recommended in FlowType and this is causing issues for end users in several libraries I author. See e.g. this issue.

Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?

This is in React 15.6.1.

STRML added a commit to react-grid-layout/react-resizable that referenced this issue Aug 31, 2017
@gaearon
Copy link
Collaborator

gaearon commented Sep 1, 2017

It’s unfortunate. React 16 is really close and it doesn’t have this issue.

We could make the getters non-enumerable I think. Not sure if that would be confusing / a breaking change?

@STRML
Copy link
Contributor Author

STRML commented Sep 1, 2017

That should fix the issue; I doubt anyone is enumerating over React for any reason other than this one, but I think that would be a breaking change.

Ideally the warning would only fire if you actually use either of these features; so some interception on PropType fns and createClass would be more exact.

@aweary
Copy link
Contributor

aweary commented Sep 1, 2017

Both of those packages export a factory function that React calls to create the package. Maybe we could wrap the exported factory result, or update the factory to accept some argument that could apply a warning at the right time?

@gaearon
Copy link
Collaborator

gaearon commented Sep 1, 2017

I’m not sure the effort to fix it (and potentially introduce other issues) is worth it given that 16 is imminent.

STRML added a commit to react-grid-layout/react-grid-layout that referenced this issue Sep 5, 2017
@Jessidhia
Copy link
Contributor

Jessidhia commented Sep 6, 2017

Why would Flow encourage a syntax that is known to be invalid and that will be broken with real modules? 🤔

But this is perhaps a discussion for another forum.

@gaearon
Copy link
Collaborator

gaearon commented Oct 3, 2017

I think we'll just leave this unfixed as we already released 16.

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

No branches or pull requests

4 participants