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

False positive with "Warning: You are manually calling a React.PropTypes validation function" #8326

Closed
davidgilbertson opened this issue Nov 17, 2016 · 1 comment

Comments

@davidgilbertson
Copy link
Contributor

davidgilbertson commented Nov 17, 2016

OS: macOs 10.12.1
Node: 6.6.0
NPM: 3.10.3
React: 15.1.0

I am getting the warning

Warning: You are manually calling a React.PropTypes validation function for the `name` prop on `Greeting`. 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.

I've inherited a codebase with an interesting setup that uses an npm package (and therefore a different react instance) to render the DOM (details below). This comment makes me wonder if that could be the cause of the issue? The package is using 15.1 but the component is defined with React 15.3.2.

To test, I copied code straight from the docs so I'm quite sure that the warning isn't warranted.

class Greeting extends React.Component {
  render() {
    return (
      <h1>Hello, {this.props.name}</h1>
    );
  }
}

Greeting.propTypes = {
  name: React.PropTypes.string
};

I'm still getting my head around the architecture of my codebase, but it does something like this:

  • A node server waits for requests.
  • in server.js it imports a component, say App.jsx (defined with React instance 1)
  • in server.js it imports react-template-server (an internal library, as an npm package)
  • when a request comes in, it passes App.jsx to the react-template-server instance
  • react-template-server imports react-dom (which I guess is React instance 2?) and uses that to render the passed in component, and returns the rendered HTML.

If I take the render logic out of the package and bring it up into the app, I don't get the warning.

@gaearon
Copy link
Collaborator

gaearon commented Nov 17, 2016

Using different versions of react to define and render components in the same project is not supported. We can't really help here because they are just not compatible.

@gaearon gaearon closed this as completed Nov 17, 2016
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