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

React PropTypes and createClass warnings #3385

Closed
AlexJF opened this issue Sep 7, 2017 · 6 comments
Closed

React PropTypes and createClass warnings #3385

AlexJF opened this issue Sep 7, 2017 · 6 comments
Labels

Comments

@AlexJF
Copy link

AlexJF commented Sep 7, 2017

Are you submitting a bug report or a feature request?

Bug report

What is the current behavior?

When running jest unit tests touching redux-form related code, those tests log React warnings to the console:

console.warn node_modules\react\lib\lowPriorityWarning.js:40
      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
    console.warn node_modules\react\lib\lowPriorityWarning.js:40
      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?

No warnings :)

What's your environment?

Redux-form 7.0.4
Babel 6.26.0
Jest 21.0.1
Flow 0.49.1
React 15.6.1

Other information

Related issue: facebook/flow#4673

Culprits: https://github.com/erikras/redux-form/search?l=JavaScript&q=%22+import+%2A+as+React%22+&type=&utf8=%E2%9C%93

@slavab89
Copy link

slavab89 commented Sep 7, 2017

I actually see this as well, but on my SSR build.
This happens since 7.0.4. I dont see this message on 7.0.3

@gustavohenke
Copy link
Collaborator

Hi folks, thanks for the report!
This really seems to be code added as per v7.0.4 release. Please see #3387 for a potential fix 😉

@erikras
Copy link
Member

erikras commented Sep 7, 2017

I saw this during my tests, but could not figure out where it was coming from, as I was not specificaly importing PropTypes from anywhere. Good work by @gustavohenke on the fix.

The import * from React was taken directly from the Flow docs.

@erikras
Copy link
Member

erikras commented Oct 6, 2017

Published fix in v7.1.0.

@nerfologist
Copy link

Hello @erikras, unfortunately I'm still experiencing these warnings in Jest after upgrading to v7.1.0. Grepping through the v7.1.0 version I found the following imports which may be the culprits:

✎  $ ag "from 'react'" | grep '*'
src/FieldArrayProps.types.js.flow:2:import * as React from 'react'
src/FieldProps.types.js.flow:4:import * as React from 'react'
src/FieldsProps.types.js.flow:2:import * as React from 'react'
src/immutable.js.flow:2:import * as React from 'react'
src/index.js.flow:2:import * as React from 'react'

I was able to confirm that this import causes the yellow warning in Jest:

  console.warn node_modules/react/lib/lowPriorityWarning.js:40
    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

  console.warn node_modules/react/lib/lowPriorityWarning.js:40
    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

HTH, thanks for your amazing work!

@lock
Copy link

lock bot commented Oct 9, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Oct 9, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

5 participants