[SOLVED] How to restart app (react native and expo)

Issue

I use expo so I’ve no access to android folder.

I want to restart my app for first time. How can I do that?

I use react-native-restart, but not wroking and I have an error now:

null is not an object (evaluating ‘x.default.restart;)

Codes:

  componentDidMount() {
    if (I18nManager.isRTL) {
      I18nManager.forceRTL(false);
      RNRestart.Restart();
    }
  }

How Can I restart my app?

Solution

I’ve had the same problem for over a month, nothing helped me, so I developed a library to accomplish this, simple install it using:

npm i fiction-expo-restart

and import it like:

import {Restart} from 'fiction-expo-restart';

and then when you want to perform a restart, use:

Restart();

Note in case this answer gets old, you can check the library here: https://www.npmjs.com/package/fiction-expo-restart

Answered By – Faisal Shahzad

Answer Checked By – Clifford M. (BugsFixing Volunteer)

Leave a Reply

Your email address will not be published.