[英]React Native mapStateToProps not setting state +Redux
This could be an issue with my understanding of how RN runs, but I have a working WebApp and am using the same Redux
setup. 我对RN的运行方式了解可能是个问题,但是我的WebApp正常运行,并且正在使用相同的
Redux
设置。 When I run a dispatch
action I do see the proper information in the console as the call is successful, however I am not seeing the proper interaction within the app. 当我执行
dispatch
操作时,在调用成功后,确实在控制台中看到了正确的信息,但是在应用程序中却看不到正确的交互。
I'm providing a Gist Link to avoid leaving out important pieces of the components, but these are the 3 components involves presently. 我提供了一个Gist Link,以避免遗漏重要的组件,但这是目前涉及的3个组件。
In my Web App, I initiate the store in index.js - 在我的Web应用程序中,我在index.js中启动商店-
I tried to implement this within RN a few ways: 我尝试通过几种方法在RN中实现此目标:
App.js
initiated the store - Works. App.js
启动了商店App.js
。
HomeScreen.js
initiated the dispatch - Made the call but didn't update the state HomeScreen.js
启动了调度-进行了调用但未更新状态
Character.js
mappedStateToProps
- Didn't work as there was no state. Character.js
mappedStateToProps
无法使用,因为没有状态。
None of this seemed to make a difference; 这些似乎都没有改变。 I don't know if I'm abusing
App.js
in RN for expecting it to do too much lifting compared to App.js
of ReactJS. 我不知道如果我滥用
App.js
在RN的期待相比,它做太多的提升App.js
ReactJS的。
Welcome any input. 欢迎任何意见。
在HomeScreen容器中,您需要在mapDispatchToProps方法中使用bindActionCreators 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.