首页 > 解决方案 > componentDidMount 换屏

问题描述

在屏幕之间切换时是否启用数据调用。

我可以用这段代码调用一次

async componentDidMount() {
 return fetch("https://www.xxxx.com/app/messages", options)
}

标签: react-native

解决方案


我解决了

async componentDidMount() {
    this.load()
    this.props.navigation.addListener('willFocus', this.load)
}
load = async () => { }

推荐阅读