[英]Bad Errors for PropType (React)
My code seems to be throwing incorrect PropType errors. 我的代码似乎抛出了错误的PropType错误。
SomeComponent = React.createClass({
propTypes: {
someFunction: React.PropTypes.func.isRequired
},
...});
SomeOtherComponent = React.createClass({
internalFunction: function(){
console.log('test!');
},
render: function(){
return <SomeComponent someFunction={this.internalFunction}/>
}
...});
Getting that console.log to trigger isn't a problem at all, but I'm getting a prop type mismatch error on the func
in the console as soon as the page loads. 触发该console.log根本不是问题,但是一旦页面加载,我就在控制台的func
上遇到了prop类型不匹配错误。
How is it possible to have an error message and have access to the function? 如何显示错误消息并可以使用该功能?
Found the issue. 找到了问题。
Had func.required
instead of func.isRequired
on the propTypes and just completely overlooked it. 在func.isRequired
上使用func.required
而不是func.isRequired,只是完全忽略了它。 ah well. 呃,好吧。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.