MCPcopy Index your code
hub / github.com/avishayil/react-native-restart

github.com/avishayil/react-native-restart @v0.0.28

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.0.28 ↗ · + Follow
39 symbols 76 edges 28 files 4 documented · 10% 5 cross-repo links
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

On October 7th, 2023 Hamas terrorists launched a unilateral attack on Israel, brutally killing thousands of civilians, including infants and children, taking 240 hostages, and injuring thousands more.

MORE THAN 110 HOSTAGES REMAIN IN CAPTIVITY. BRING THEM HOME NOW! #BringThemHomeNow

React Native Restart

npm version npm downloads Build status

Sometimes you want to reload your app bundle during app runtime. This package will allow you to do it.

iOS GIF Android GIF

Installation

  • Using react-native < 0.62? install react-native-restart@0.0.17
  • Using 0.71 > react-native >= 0.62? install react-native-restart@0.0.24
  • Using 0.72 - 0.84? install react-native-restart@0.0.28
  • Using react-native >= 0.85? install react-native-restart@0.0.28 and above

Requirements

For React Native 0.85.3+: - React Native 0.85.3+ - React 19.2.3+ - Node.js 20.19.4+ (or 22.13.0+, 24.3.0+, 25.0.0+) - iOS 15.1+ - Xcode 16.1+ - Android API 24+ (Android 7.0+) - Android SDK 36 - Java 17 (for Android development) - Gradle 9.3.1

With yarn

$ yarn add react-native-restart

With npm

$ npm install --save react-native-restart

Auto-Linking Setup (react-native >= 0.60)

iOS

$ cd ios
$ pod install

Android

No further steps should be taken

Automatic Installation (Without Auto-Linking)

react-native link react-native-restart or npm install -g rnpm && rnpm link react-native-restart

Manual Android Installation

In android/settings.gradle

...

include ':react-native-restart'
project(':react-native-restart').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-restart/android')

In android/app/build.gradle

...

dependencies {
    ...

    implementation project(':react-native-restart')
}

Register module (in MainApplication.java)

import com.reactnativerestart.RestartPackage;  // <--- Import

public class MainApplication extends Application implements ReactApplication {

    private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
        ......

          /**
         * A list of packages used by the app. If the app uses additional views
         * or modules besides the default ones, add more packages here.
         */
        @Override
        protected List<ReactPackage> getPackages() {
            ...
            return Arrays.<ReactPackage>asList(
                    new MainReactPackage(),
                    new RestartPackage() // Add this line
            );
        }
    };
    ......
};

Manual iOS Installation

Importing The Library

  • 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!

Add Files To...

Library Imported Successfully

  • Ensure that libRestart.a is linked through Link Binary With Libraries on Build Phases:

Library Linked

  • Ensure that Header Search Paths on Build Settings has the path $(SRCROOT)/../node_modules/react-native-restart set to recursive:

  • You're All Set!

CocoaPod iOS Installation

In your ios/Podfile make sure to use react-native-restart from the local node_modules/. With that, only your project Pod needs to be linked and no extra configuration is required:

target 'MyReactApp' do
  # Make sure you're also using React-Native from ../node_modules
  pod 'React', :path => '../node_modules/react-native', :subspecs => [
    'Core',
    'RCTActionSheet',
    # ... whatever else you use
  ]
  # React-Native dependencies such as yoga:
  pod 'yoga', path: '../node_modules/react-native/ReactCommon/yoga'

  # The following line uses react-native-restart, linking with
  # the library and setting the Header Search Paths for you
  pod 'react-native-restart', :path => '../node_modules/react-native-restart'
end

Remember to run cd ios && pod install to update files used by Xcode.

Usage

import RNRestart from 'react-native-restart'; // Import package from node modules

// Immediately reload the React Native Bundle
RNRestart.Restart(); // Deprecated
RNRestart.restart();

Contributing

Contributions are welcome. Please see CONTRIBUTING.md if you like to contribute to this library.

Credits

Thanks to Microsoft CodePush library. I simply extracted the code from their library's logic to reload the React Native Bundle.

Extension points exported contracts — how you extend this code

ReactInstanceHolder (Interface)
(no doc) [1 implementers]
android/src/main/java/com/reactnativerestart/ReactInstanceHolder.java

Core symbols most depended-on inside this repo

Restart
called by 2
windows/ReactNativeRestart/RNRestart.h
getReactInstanceManager
called by 2
android/src/main/java/com/reactnativerestart/ReactInstanceHolder.java
loadBundleLegacy
called by 2
android/src/main/java/com/reactnativerestart/RestartModule.java
loadBundle
called by 2
android/src/main/java/com/reactnativerestart/RestartModule.java
restart
called by 2
android/src/main/java/com/reactnativerestart/RestartModule.java
normalizeReactNativeDeps
called by 2
Example/scripts/updateReactNativeVersion.js
getReactInstanceManager
called by 1
android/src/main/java/com/reactnativerestart/RestartModule.java
resolveInstanceManager
called by 1
android/src/main/java/com/reactnativerestart/RestartModule.java

Shape

Method 22
Function 10
Class 6
Interface 1

Languages

Java44%
TypeScript26%
C++18%
Kotlin13%

Modules by API surface

android/src/main/java/com/reactnativerestart/RestartModule.java12 symbols
windows/ReactNativeRestart/RNRestart.h4 symbols
android/src/main/java/com/reactnativerestart/RestartPackage.java3 symbols
Example/scripts/updateReactNativeVersion.js3 symbols
Example/scripts/__tests__/bumpTemplateVersion-test.js3 symbols
Example/android/app/src/main/java/com/example/MainActivity.kt3 symbols
windows/ReactNativeRestart/ReactPackageProvider.h2 symbols
android/src/main/java/com/reactnativerestart/ReactInstanceHolder.java2 symbols
Example/android/app/src/main/java/com/example/MainApplication.kt2 symbols
windows/ReactNativeRestart/ReactPackageProvider.cpp1 symbols
src/index.tsx1 symbols
Example/scripts/updateTemplateVersion.js1 symbols

For agents

$ claude mcp add react-native-restart \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page