React-native: Getting proptype warning errors for FB components

Created on 2 Aug 2016  Â·  16Comments  Â·  Source: facebook/react-native

Since upgrading to 0.30.0, we are now getting many, many warnings not to manually call React.Proptypes validation functions. But these are not in our code, they're in RCT code.

Two of many:

ExceptionsManager.js:76 Warning: You are manually calling a React.PropTypes validation function for the borderBottomRightRadius prop on RCTImageView. 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.

ExceptionsManager.js:76 Warning: You are manually calling a React.PropTypes validation function for the translateY prop on TouchableHighlight. 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.

We've updated all our modules, so…

Locked

Most helpful comment

The fix is to use the version of React that is specified by

require('react-native/package.json').peerDependencies.react

For RN 0.30 and 0.31: npm install react@~15.2.1
For RN 0.32: npm install react@~15.3.0

All 16 comments

I'm experiencing the same thing after upgrading to 0.30.0, getting probably hundreds of these.

We're also experiencing hundreds of these...

+1 with 0.29.0

It's related to React 15.3.0 https://github.com/facebook/react/releases
I shield these warn by comment Related code in react/lib/ReactPropTypes.js line 119 -122

        // if (!manualPropTypeCallCache[cacheKey]) {
        //   process.env.NODE_ENV !== 'production' ? warning(false, 'You are manually calling a React.PropTypes validation ' + 'function for the `%s` prop on `%s`. 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.', propFullName, componentName) : void 0;
        //   manualPropTypeCallCache[cacheKey] = true;
        // }

I downgraded to React 15.2.1 until a fix for this is issued

Is there any workaround for this issue?

Same issue with react 15.3.0 and react-native 0.30.0

That's why you should stick to required peer dependencies: react-native requires react@~15.2.0, which does not include react 15.3, only versions >= 15.2 and < 15.3 (even if I also tried it haha).
This change from ^ to ~ was recently introduced in react-native to avoid this kind of issue.

But if you want to ignore that peer dependency requirement and use react 15.3 anyway, you can apply @ios122's hack by removing lines 116-124 from node_modules/react/lib/ReactPropTypes.js:

if (process.env.NODE_ENV !== 'production') {
  if (secret !== ReactPropTypesSecret && typeof console !== 'undefined') {
    var cacheKey = componentName + ':' + propName;
    if (!manualPropTypeCallCache[cacheKey]) {
      process.env.NODE_ENV !== 'production' ? warning(false, 'You are manually calling a React.PropTypes validation ' + 'function for the `%s` prop on `%s`. 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.', propFullName, componentName) : void 0;
      manualPropTypeCallCache[cacheKey] = true;
    }
  }
}

@antoinerousseau I've updated react after install react-addons-pure-render-mixin. So, I've installed both 15.2 versions and all works fine again :smile:

+1, ETA for an official fix?

The fix is to use the version of React that is specified by

require('react-native/package.json').peerDependencies.react

For RN 0.30 and 0.31: npm install react@~15.2.1
For RN 0.32: npm install react@~15.3.0

Which commit(s) fixed this issue in RN 0.32? I'd like to avoid these warnings in react-native-web.

Edit: for the curious it was 5db5ee9f556ee0486f4e805425807fc74e23a9d3

I also downgraded to React 15.2.1 until a fix for this is issued

Thanks to @ide, replace
"react": "^15.2.1",
to
"react": "~15.2.1",
fix all the warnings, love. (react-native ^0.31.0)

Was this page helpful?
0 / 5 - 0 ratings