npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-restart

v0.0.27

Published

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

Downloads

396,252

Readme

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

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.