每次打开应用程序本机应用程序时都可以重新加载吗?

时间:2020-01-07 21:41:50

标签: react-native expo

我有一个基于Expo的应用程序反应。在应用程序中,我会跟踪今天,昨天等的销售记录。请参阅所附照片: enter image description here

问题是如果今天过去了,明天我检查应用程序了,它仍然显示与昨天相同的数据。如果我注销应用程序并重新登录,它将正确显示数据。但是,如何在每次打开应用程序时都刷新我的应用程序,而无需注销并登录?

1 个答案:

答案 0 :(得分:0)

我想以下代码会有所帮助。我是从Reddit帖子中获得的:https://www.reddit.com/r/reactnative/comments/9b8k4b/how_to_re_render_tab_screens_after_visiting_one/

componentDidMount () {
  const {navigation} = this.props;
  navigation.addListener ('willFocus', () =>
    // run function that updates the data on entering the screen
  );
}