-5

I am working on a react-native app where I want to auto Reload a page can anyone tell me how can we do that in react-native code, I have three component in which one component has to drop down I just want to reload the current screen this is the image of my page in which when a person changes the language i want to reload the page

Kartikey
  • 4,516
  • 4
  • 15
  • 40
Jasmin Raval
  • 184
  • 1
  • 5
  • 15
  • your question is not clear. please give me more information about your problem. do you want to refresh data in your screen? refresh data coming from an api?refresh your emulator?.. – Ali SabziNezhad Jun 23 '18 at 09:25

5 Answers5

1

use setTimeout on componentDidMount() to reload page.

example:

setTimeout(() => {
    this.setState({time: true})
}, 1000)
Ali SabziNezhad
  • 3,050
  • 1
  • 17
  • 31
Yash Vaghela
  • 562
  • 1
  • 5
  • 16
0

You can use forceupdate see https://reactjs.org/docs/react-component.html#forceupdate

forceupdate will re-render the component.

Priya
  • 1,410
  • 14
  • 22
  • thank you for the solution but forceUpdate is not working because it will update the current component but we have three different components in the single page – Jasmin Raval Jun 23 '18 at 10:05
0

https://facebook.github.io/react-native/docs/refreshcontrol.html

this is the guide for react native Refresh Component, usually we create function _onRefresh(), and you can callit at some specific time intervel.

Hope this answer will help you.

Kedar Dave
  • 471
  • 12
  • 25
0

I'm assuming you are talking about auto-refreshing altered components in the simulator.

You would want to Enable Hot Reloading in the iOS or Android simulator.

You can pull up the developer screen in the iOS simulator showing Hot Reloading by pressing CMD + D.

  • thank you for the solution but this solution is not working because it will reload the entire app I just want to reload the current page – Jasmin Raval Jun 23 '18 at 10:01
  • @jasminraval You're probably mixing up **Live Reloading** and **Hot Reloading**. [Here's an explanation.](https://stackoverflow.com/questions/41428954/what-is-the-difference-between-hot-reloading-and-live-reloading-in-react-native) Basically, Hot Reloading should accomplish what you're looking for. – Russell Goldman Jun 23 '18 at 21:44
0

Simple precise and clear!

componentWillMount(){
    this._subscribe = this.props.navigation.addListener('didFocus', () => {
     this.LoadData();
     //Put your Data loading function here instead of my this.LoadData()
    });}
Rishav Kumar
  • 4,979
  • 1
  • 17
  • 32