Add react-native-restart support
closed
Oron cohen
Very important feature that currently I did not find any solution for it:
It was closed before, because the reload operation in Updates should do the job, however, I checked and it doesn't work.
Brent Vatne
closed
use Updates.reloadAsync()
Gregory Zhukovsky
Brent Vatne: please see my reply below. Should I open an issue?
Brent Vatne
can you explain how it "doesn't work"? https://docs.expo.io/versions/v38.0.0/sdk/updates/#updatesreloadasync this method does work as described
Oron cohen
Brent Vatne: I have tried to use it on the app loading on standalone android (to not allow RTL). It didn't do anything without an update.
Gregory Zhukovsky
Brent Vatne: Like Oron said, it doesn't work if you just need to restart an app without any update available. Most people on the net that I see looking for this feature need to solve the problem with forcing the RTL layouts on LTR devices https://github.com/expo/expo/issues/1969
Brent Vatne
Gregory Zhukovsky: perhaps this was true at some point, but it is not right now. here is an example app using
Updates.reloadAsync
to switch between ltr/rtl. build it with expo build:ios -t simulator
or expo build:android -t apk
to verify it works as expected (i did, it does) https://github.com/brentvatne/updates-reloadGregory Zhukovsky
Brent Vatne: your example works. In fact,
Updates.reloadAsync
always reloads when used in a component. But - it doesn't work when used in a hook. Please look at https://github.com/grreeenn/updates-reload, I've forked your example and modified it with a concept of a startup hook from expo init
boilerplate; you can see both of the console.log
s from the useStartupHook.js
, but the app does not reload. Do I miss something here?Brent Vatne
Gregory Zhukovsky: the problem with this example appears to be that
Updates.reloadAsync
is called immediately when the app is loaded. if you wrap it in even a 100ms timeout that will resolve it: setTimeout(reloadAsync, 100);
this does seem like something expo-updates should handle gracefully but it should not block you from using
reloadAsync
for this use case in your appBrent Vatne
i filed an issue for making
reloadAsync
work immediately when the app starts, without any timeout, here: https://github.com/expo/expo/issues/10598Gregory Zhukovsky
Brent Vatne: ok, I wouldn't have find it on my own. Thank you :)