Search code examples
reactjsreact-nativereact-native-iosasyncstorage

REACT NATIVE - How to call Fast Refresh in code?


My app has a save feature that uses AsyncStorage but whenever I save data, I need to refresh the app to see the changes. The Fast Refresh feature in my Expo is working great. but what I actually want is to use Fast Refresh in my code so that whenever I save data my app will automatically Fast Refresh itself. Is that possible?


Solution

  • Ciao try to re-render the component by using this.forceUpdate() in this way:

    someMethod() {
      // Force a render without state change...
      this.forceUpdate();
    }
    

    Anyway, you could avoid this by putting a state var in render function and chenge it when you want to re-render component. It's easier and more compliant to react logic.

    For more info check here.