【发布时间】:2019-08-15 16:16:29
【问题描述】:
我无法从我的 redux-form 访问 redux 状态。
我查看了How to access the redux store within the redux form,但这些解决方案都不起作用。
class PersonalInfo extends Component {
renderContent() {
console.log(this.state)
......
}
function mapStateToProps(state) {
return {
state
};
}
export default reduxForm({
form: "AccountOverview",
})(connect(mapStateToProps)(PersonalInfo))
当我使用 console.log(this.state) 或 state 时它会导致 null
【问题讨论】:
-
如果您想从状态中获取初始值,可能值得一读:redux-form.com/8.2.2/examples/initializefromstate