RN刷新回调
来源:互联网 发布:淘宝店卖肉需要执照吗 编辑:程序博客网 时间:2024/06/07 07:50
有的时候我们需要从A进入B,然后B返回到A,A同时也需要刷新
A的代码(在进入B时传入刷新要用到的函数)
goGouWu() { //alert('点击了去购物车'); const { navigator } = this.props; //为什么这里可以取得 props.navigator?请看上文: //<Component {...route.params} navigator={navigator} /> //这里传递了navigator作为props let _that=this; if (navigator) { navigator.push({ name: 'GouWu', component: GouWu, params: { fetchData: function () { console.log('启动fetchData里的方法了'); AsyncStorage.clear(function (err) { if (!err) { _that.setState({ count: 0, }); alert('购物车已经清空'); } }); } } }) } }
B再返回之前先调用刷新函数
clearStorage() { //触发一下回调 让数据同步 console.log('点击了清空购物车'); if (this.props.fetchData) { console.log('点击了清空购物车----回调去影响List页面'); this.props.fetchData(); } const { navigator } = this.props; if (navigator) { navigator.pop(); } }
阅读全文
0 0
- RN刷新回调
- RN
- RN
- RN
- RN
- RN中Reload之后界面不刷新的问题
- RN-react-native-pull-下拉刷新、上拉加载
- Beautiful RN
- RN入门
- RN学习
- RN备忘
- RN填坑记
- RN颜色
- RN stylesheet
- RN Navigator
- RN-Init
- RN-Demo
- RN-API
- 三、Jenkins系列_插件安装及报错处理
- Python中的split()函数的用法
- Python学习之初始(一)
- 数组与矩阵---需要排序的最短子数组长度
- HDU 6194 string string string
- RN刷新回调
- Leetcode 169.Majority Element
- day7
- Oracle触发器用法实例详解
- Binary Tree Zigzag Level Order Traversal
- 树链剖分-专题
- spring MVC配置详解
- Java的反射机制(一)
- 很全的 Python 面试题