在 React Native (Class Component) 中自动刷新页面

Refresh the page automatically in react native (Class Component)

我有一个订单屏幕,我正在从 API 获取它的数据。有什么方法可以自动刷新屏幕,因为我必须重新启动应用程序才能获取新数据

对于这种情况,您希望在新订单到达时接收订单,而无需用户刷新屏幕。你需要实现Socket才能实现。

尝试创建可重复使用的方法 以从 API 获取更新数据并在 onApprove 或时调用 API onReject 动作发生。

喜欢:

loadData = async () => {
    /*
    *  Process your api call here...
    */
}

onApprove = async () => {
    /*
    *  Process your approve button press and then call the loadData again
    */
    await loadData()
}

onReject = async () => {
    /*
    *  Process your rejecgt button press and then call the loadData again
    */
    await loadData()
}

此外,维护列表刷新功能以在加载数据时适当地显示加载程序