为什么console没有提示信息??var MyTitle = React.createClass({ propTypes:{ title:React.PropTypes.isRequired,
}, render:function(){ return <h1>{this.props.title}</h1>;
}
});var data = 10;
ReactDOM.render(<MyTitle />,document.body);
1 回答
![?](http://img1.sycdn.imooc.com/5333a1660001394602000200-100-100.jpg)
阿波罗的战车
TA贡献1862条经验 获得超6个赞
因为校验只在development mode
中生效:
As your app grows it's helpful to ensure that your components are used correctly. We do this by allowing you to specify propTypes. React.PropTypes exports a range of validators that can be used to make sure the data you receive is valid. When an invalid value is provided for a prop, a warning will be shown in the JavaScript console. Note that for performance reasons propTypes is only checked in development mode
看文档:Prop Validation
至于如何开启/禁用development mode
,看这里:How to turn on/off ReactJS 'development mode'?
添加回答
举报
0/150
提交
取消