PropType 验证不在控制台中显示警告
PropType validation does not show warning in console
我正在将 React 与 ASP.NET 一起使用,并且正在尝试实施 propType 验证。但是我没有收到任何警告,即使我传递给我的组件的道具显然无效:
var LoginBox = React.createClass({
propTypes: {
// the 'url' prop is not given and should result in a warning
url: React.PropTypes.string.isRequired,
// given 'modalId' is a a string and should result in a warning as well
modalId: React.PropTypes.bool
},
// some other functions ...
render() { ... }
)};
ReactDOM.render(
<LoginBox modalId="forgotModal" loginUrl="/user/login" />,
document.getElementById('content')
);
我没有正确使用验证吗?
您正在使用 react(.min.js
) 的生产版本,propTypes
那里禁用了警告。
我正在将 React 与 ASP.NET 一起使用,并且正在尝试实施 propType 验证。但是我没有收到任何警告,即使我传递给我的组件的道具显然无效:
var LoginBox = React.createClass({
propTypes: {
// the 'url' prop is not given and should result in a warning
url: React.PropTypes.string.isRequired,
// given 'modalId' is a a string and should result in a warning as well
modalId: React.PropTypes.bool
},
// some other functions ...
render() { ... }
)};
ReactDOM.render(
<LoginBox modalId="forgotModal" loginUrl="/user/login" />,
document.getElementById('content')
);
我没有正确使用验证吗?
您正在使用 react(.min.js
) 的生产版本,propTypes
那里禁用了警告。