React-Bootstrap:手动调用一个React.PropTypes验证函数

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

在 2 周后回来升级我的项目后,我收到了很多我无法摆脱的警告:

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.

很明显,它们与react-bootstrap.

有关

我发现 用于 react-native,答案建议升级依赖库版本。我已经这样做了,但没有任何帮助...我还完全删除了 node_modules,然后再次重新安装。

我调查过 the issues on github 但没有类似的。

如何更正我的应用并消除警告?

我拥有的版本:

我为你创建了这个fiddle

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

一般来说,您最好尝试将此作为问题的一部分;-)

我无法重现 fiddle 中的警告。如果您使用 React Bootstrap 复制并粘贴触发此警告的代码,我很乐意再看一眼。

我通过卸载 react 15.3.0react 15.2.0 这个版本的 React 解决了这些错误。

这是因为最新版本的react已经移除PropTypes生产环境,所以手动添加PropType会报错。

要了解更多信息,请查看 https://facebook.github.io/react/warnings/dont-call-proptypes.html