问题描述
我有前往组件的路线
<Route path='/' component={Main}
及其简化版本:
const mapDispatchToProps = dispatch => ({
create: () => dispatch(actions.create())
})
@withRouter
@connect(null,mapDispatchToProps)
class Main extends React.Component {
render() {
return <div>
Main component
</div>
}
}
Main.propTypes = {
create: PropTypes.func.isRequired
}
export {Main}
呈现组件时,控制台会引发此类版本错误(需要创建prop,但值未定义),尽管如果我console.log(this.props.create)
中的render
也会以字符串形式记录我的功能(因此props就位)
如果我修改此组件并添加propTypes,则static propTypes
错误消失。
我该如何解决?
谢谢!
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)