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 prop-types warnings #9450

Closed
coRz opened this issue Apr 18, 2017 · 13 comments
Closed

React prop-types warnings #9450

coRz opened this issue Apr 18, 2017 · 13 comments

Comments

@coRz
Copy link

coRz commented Apr 18, 2017

Hey,

I'm getting some errors after migrating to react 15
Warning: Failed Context Types: Calling PropTypes validators directly is not supported by the prop-types package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types

Is there any chance to add some indication where the error comes from, file name maybe?
I have cleaned the entire project from React.PropTypes and I do not use any other propType validators.

Thanks.

@gaearon
Copy link
Collaborator

gaearon commented Apr 18, 2017

Which versions of which packages exactly are you using? This specific message could be a false positive, as described in http://fb.me/use-check-prop-types.

@coRz
Copy link
Author

coRz commented Apr 18, 2017

React version "15.5.4"
prop-types "^15.5.7"

did yarn upgrade, now getting abit different warnings:
Warning: Accessing PropTypes via the main React package is deprecated. Use the prop-types package from npm instead
Warning: You are manually calling a React.PropTypes validation function for the path prop on Route. This is deprecated and will throw in the standalone prop-types package. You may be seeing this warning due to a third-party PropTypes library. See https://fb.me/react-warning-dont-call-proptypes for details.

should i just ignore this?

--

Dang.. my react-router outdated they fixed the issue i think ill update now.

@gaearon
Copy link
Collaborator

gaearon commented Apr 18, 2017

If you can publish a project reproducing this, it will really help! Even if you see this with an old library version. Maybe there's still a bug on our side.

@coRz
Copy link
Author

coRz commented Apr 18, 2017

Well, I kinda trying to fix my project now since everything is broken currently (redux-async-connect deprecated and using some old libs + old react version 14.something, screams at me that cannot find some react-async-connect
ERROR in ./~/redux-async-connect/lib/ReduxAsyncConnect.js Module not found: Error: Cannot resolve module 'react-router/lib/RouterContext'

bah hope I will fix it.

@gaearon
Copy link
Collaborator

gaearon commented Apr 18, 2017

I'm going to close for now since it's not clear whether you're having issues with React in particular or not. From how your error message looks it might be you have React 0.14 in the bundle somewhere. If you do, make sure to update it to 0.14.9 which fixes the false positive for the warning.

@gaearon gaearon closed this as completed Apr 18, 2017
@kalupa
Copy link

kalupa commented Apr 24, 2017

Perhaps this "warning" should have used console.warn instead of console.error which causes scripts running it to exit with a non-0 error code (and then failing our tests)

@gaearon
Copy link
Collaborator

gaearon commented Apr 25, 2017

Thanks for feedback. We do plan to use console.warn for deprecation warnings in the future: #9395.

@kalupa
Copy link

kalupa commented Apr 25, 2017 via email

@gaearon
Copy link
Collaborator

gaearon commented Apr 25, 2017

I know that in some cases people choose to treat console.errors as failures explicitly, but I wasn’t familiar with tools doing so automatically. FWIW we’ve been using console.error for deprecations since React 0.14, so it’s not something new. At the time console.warn didn‘t provide a stack trace, but we’re ready to revisit this since now it does in Chrome.

@kalupa
Copy link

kalupa commented Apr 25, 2017

I wasn't aware that these tools did so either until this issue came up. It seems a strange thing, honestly. Frustratingly there was no real behavioural failure, only the console.error causing a non-0 error code. Going to watch the warnings issue thread to keep up to date. Undoubtedly there's a way to change it in the headless browser(s) or the test runner but the fastest thing to get our tests to pass was to freeze our React version at 15.4.2 for now.

@gaearon
Copy link
Collaborator

gaearon commented Apr 25, 2017

You can also try overriding console.error. (Maybe this works, maybe it doesn't.)

console.error = console.warn;

@kalupa
Copy link

kalupa commented Apr 25, 2017

It's possible to try. Might have unintended consequences, though, so will need to proceed cautiously. Thanks for the help!

@cancerberoSgx
Copy link

Just in case others are fighting with react's console.errors, this is the way of getting rid of them.

export NODE_ENV="production"

These console.error are very annoying when you are debugging more important and broken stuff than those warnings and in that situation they make debugging almost impossible.

Warnings are warnings, errors are errors... I strongly suggest to change those to console.warn

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