Is it possible to programmatically restart a React Native app without writing any native code?
For instance, I know from the answer to this question that I can restart an Android app with:
Intent i = getBaseContext().getPackageManager() .getLaunchIntentForPackage( getBaseContext().getPackageName() ); i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(i);
Can I do the same with React Native?
Drag the file Restart. xcodeproj from /node_modules/react-native-restart/ios into the Libraries group in the Project navigator. Ensure that Copy items if needed is UNCHECKED!
Pull to Refresh functionality is implemented using RefreshControl component in React Native. RefreshControl is used inside a ScrollView or ListView to add pull to refresh functionality. When the ScrollView is at scrollY: 0 , swiping down triggers an onRefresh event.
For Android emulator press "CTRL + M" with keyboard on emulator for reloading the react native project.
If you want to restart just the JS part, then you can use React Native Restart Package. This will work on both Android and iOS.
If you want to restart the whole application, There are no react native packages as of now. If you want to create on your own, then check the following link
Building the custom Android module for React Native
If you find difficulty in writing the base JAVA code, You can generate the boilerplate using React Native Create Library
UPDATE:
From 0.62, React Native have added DevSettings.reload()
. So, if you want to reload programmatically while developing you can use that. Note that this method does not work in production!
Click here for Doc
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With