InteractionManager 坑
2018-04-18 本文已影响0人
冬天73051
Interactionmanager可以将一些耗时较长的工作安排到所有互动或动画完成之后再进行。这样可以保证JavaScript动画的流畅运行。
应用这样可以安排一个任务在交互和动画完成之后执行:
具体用法查看官网:
实际应用中出现的问题:
RN: 0.54.2
componentDidMount() {
InteractionManager.runAfterInteractions(() => {
console.log("InteractionManagerInteractionManagerInteractionManagerInteractionManagerInteractionManager")
// 请求网路数据的触发事件
this.props.dispatch(getExchangeRate({code: "CNY"}));
});
console.log("123456789456777777777777777777777777777777")
}
render() {
return(
<View>
..... 中间如果应用到动画组件什么的,如果你有动画或者什么的,会导致runAfter不会被回调,不会进入InteractionManager中,导致不能请求网络数据
</View>
)
}