Giter Site home page Giter Site logo

friederbluemle / react-native-restart Goto Github PK

View Code? Open in Web Editor NEW

This project forked from avishayil/react-native-restart

0.0 1.0 0.0 1.78 MB

React Native Package With One Purpose: To Restart Your React Native Project

License: MIT License

JavaScript 18.79% Java 37.96% Objective-C 17.67% Ruby 5.02% C# 16.68% Shell 0.06% TypeScript 1.68% Starlark 2.14%

react-native-restart's Introduction

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();

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.

react-native-restart's People

Contributors

avishayil avatar saeedzhiany avatar dependabot[bot] avatar mortezaalizadeh avatar barbieri avatar newomble avatar barzhomi avatar o-verbeek avatar mehthabux avatar ayaahmed177 avatar psiiirus avatar raphcayou avatar rafao avatar parndt avatar madsleejensen avatar l-x-c avatar kingdark1234 avatar jasonalmaturner avatar lachenmayer avatar bweissbart avatar allan-cornet-eove avatar jkomyno avatar azizghuloum avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.