我原来的写法
import React, { Component, PropTypes } from 'react';
export default class CommonTitle extends Component {
render() {
return (
…
)
}
}
CommonTitle.propTypes = {
onTitleClick: PropTypes.func.isRequired
}
PropTypes 放在了react 中引入,但是还是出错Undefined is not an object(evaluating ‘_react2.PropTypes.func’)
正确写法:
import React, { Component } from 'react';
import PropTypes from 'prop-types';
把PropTypes 从prop-types 中引入