Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to restart app (react native and expo)

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?

like image 379
Alireza Avatar asked Aug 02 '19 16:08

Alireza


1 Answers

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

like image 199
Faisal Shahzad Avatar answered Nov 12 '22 13:11

Faisal Shahzad