React native 调用mapdispatchtoprops发送thunk后,componentdidmount中未定义我的对象
我试图在渲染组件时自动将数据渲染到该组件。 我在mapDispatchToProps中启动了一个thunk,它从我的Firebase数据库获取数据并将其添加到我的redux状态。我已经设置了我的组件did mount,以正确触发调度,如我的 正如您所看到的,对象返回未定义,但是如果我通过模拟器中的按钮触发这些操作,它将返回对象。我知道这与组件生命周期有关,我应该在组件中做些什么吗?在组件挂载之前,我会收到道具吗 这是我的组件DidMount、mapdispatchtoprops和mapstatetopropsReact native 调用mapdispatchtoprops发送thunk后,componentdidmount中未定义我的对象,react-native,components,React Native,Components,我试图在渲染组件时自动将数据渲染到该组件。 我在mapDispatchToProps中启动了一个thunk,它从我的Firebase数据库获取数据并将其添加到我的redux状态。我已经设置了我的组件did mount,以正确触发调度,如我的 正如您所看到的,对象返回未定义,但是如果我通过模拟器中的按钮触发这些操作,它将返回对象。我知道这与组件生命周期有关,我应该在组件中做些什么吗?在组件挂载之前,我会收到道具吗 这是我的组件DidMount、mapdispatchtoprops和mapstate
componentDidMount() {
const { onMountFetchUsers } = this.props
onMountFetchUsers()
const nameParsed = JSON.stringify(this.props.names)
console.log("nameParsed =" + nameParsed);
}