[20190114] react 数据类型验证异常

TypeError: Cannot read property 'string' of undefined

据查从15.5开始 React.PropTypes助手函数已被弃用,改用prop-types 库

import PropTypes from 'prop-types';
 
class Greeting extends React.Component {
  render() {
    return (
      

Hello, {this.props.name}

); } } Greeting.propTypes = { name: PropTypes.string };

参见 https://blog.csdn.net/Super_LD/article/details/80717232

你可能感兴趣的:([20190114] react 数据类型验证异常)