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

Can't isomorphically check propTypes in react-dom-stream SSR without warnings in React 15.2+ #7765

Closed
jedwards1211 opened this issue Sep 18, 2016 · 4 comments

Comments

@jedwards1211
Copy link
Contributor

jedwards1211 commented Sep 18, 2016

aickin/react-dom-stream#22

react-dom-stream helpfully checks propTypes while rendering static HTML to a stream. But of course React 15.2+ warns (in this case on a user Html Component with propTypes.head):

Warning: You are manually calling a React.PropTypes validation function for the head prop on Html. This is deprecated and will not work in the next major version. You may be seeing this warning due to a third-party PropTypes library. See https://fb.me/react-warning-dont-call-proptypes for details.

The page at that link advises 3rd party libraries to use external PropType libraries, but that won't work in this case because react-dom-stream is trying to call the propTypes the user has put on their components, rather than providing helpers like the 3rd party libraries the author of that page seems to be considering (e.g. ImmutablePropTypes). To prevent these errors, the user would have to remove the propTypes on their components or replace the usages of React.PropTypes in their own code with some other library. If they were using 3rd party components that declare propTypes, they would be out of luck.

Is there an intended solution to this or was this conflict unanticipated?

@jedwards1211 jedwards1211 changed the title Can't isomorphically check propTypes in react-dom-stream SSR without warnings in React 15.2 Can't isomorphically check propTypes in react-dom-stream SSR without warnings in React 15.2+ Sep 18, 2016
@gaearon
Copy link
Collaborator

gaearon commented Sep 18, 2016

The warning is a false positive, you can safely ignore it.

It occurs because react-dom-stream is a fork of [email protected] but you’re using [email protected] for defining components. So they’re not quite compatible.

There are a few solutions but they’re not on our side:

  • Update react-dom-stream to fork of a version of React more recent than 15.3.0.
  • Or try to cherry-pick Warn if PropType function is called manually #7132 into react-dom-stream.
  • Or ignore the warning until react@16 where it’s going to be removed.
  • Or stay on react < 15.3.x until react@16 ships.

I hope this helps! react-dom-stream is a cool experiment but we don’t officially provide support for it, and things might break once in a while if somebody doesn’t keep it up to date.

@jedwards1211
Copy link
Contributor Author

Okay, I was actually concerned that react@16 would break react-dom-stream entirely, but as long as it remains possible to call the validators in dev mode there's no problem.

I'm confused what you mean about cherry-picking #7219 though? I was expecting some kind of code change, not a documentation change.

Thanks!

@gaearon
Copy link
Collaborator

gaearon commented Sep 18, 2016

Oops sorry. I meant #7132.

@gaearon
Copy link
Collaborator

gaearon commented Sep 18, 2016

Okay, I was actually concerned that react@16 would break react-dom-stream entirely, but as long as it remains possible to call the validators in dev mode there's no problem.

The warning exists to make it clear for people who call PropTypes manually (e.g. to validate their API responses, or for other obscure reasons) that this won’t work in production in 16. We warn in development because that’s where people will see the warnings, as almost nobody looks into production warning logs. But PropTypes will keep working in development for sure, even in 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

2 participants