React-Bootstrap: manually calling a React.PropTypes validation function

青春壹個敷衍的年華 提交于 2019-12-11 14:48:29

问题


After upgrading my project after coming back to it after 2 weeks I receive lots of warning I can't get rid of:

warning.js:44 Warning: You are manually calling a React.PropTypes validation function for the onClick prop on NavbarToggle. 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.

warning.js:44 Warning: You are manually calling a React.PropTypes validation function for the onClick prop on NavItem. 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.

Obviously, they have something to do with react-bootstrap.

I have found a similar question for react-native where the answers suggest to upgrade dependent libraries versions. I have done so but it didn't no help... I also removed node_modules completely and then reinstalled again.

I have looked into the issues on github but there ain't a similar one.

How can I correct my app and dismiss the warnings?

Versions I have:

  • react@15.3.0
  • react-bootstrap@0.30.2

回答1:


I created this fiddle for you:

var Hello = React.createClass({
  render: function() {
    return <div><NavItem /></div>;
  }
});
ReactDOM.render(
  <Hello name="World" />,
  document.getElementById('container')
);

In general, it’s best that you try to do this as part of the question ;-)

I can’t reproduce the warning in that fiddle. If you copy and paste the code using React Bootstrap that triggers this warning, I’ll be happy to take another look.




回答2:


I solved these errors by uninstalling this version of react which is react 15.3.0 to react 15.2.0.

This is because the latest version of react has removed PropTypes from production, so manually adding the PropType will throw an error.

To get more info about this, check out https://facebook.github.io/react/warnings/dont-call-proptypes.html



来源:https://stackoverflow.com/questions/38998249/react-bootstrap-manually-calling-a-react-proptypes-validation-function

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!