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 🙏

© 2025 – Pkg Stats / Ryan Hefner

react-native-instanceloader

v1.1.0

Published

Run multiple RN instances

Readme

react-native-instanceloader

Getting started

$ npm install react-native-instanceloader --save or $ yarn add react-native-instanceloader

Mostly automatic installation

$ react-native link react-native-instanceloader

iOS

No more instructions.

Android

  1. Add a new activity description in AndroidManifest.xml
<activity
	android:name="com.hongchuangtech.enhancer.HCTReactActivity"
	android:label="@string/app_name"
	android:theme="@style/Theme.AppCompat.Light.NoActionBar" />
  1. Make sure your RN code is in ReactActivity.
  2. Extend your MainApplication from com.hongchuangtech.enhancer.HCTReactApplication

Manual installation

iOS

  1. In XCode, in the project navigator, right click LibrariesAdd Files to [your project's name]
  2. Go to node_modulesreact-native-instanceloader and add HCTInstanceloader.xcodeproj
  3. In XCode, in the project navigator, select your project. Add libHCTInstanceloader.a to your project's Build PhasesLink Binary With Libraries
  4. Run your project (Cmd+R)

Android

  1. Open up android/app/src/main/java/[...]/MainActivity.java
  • Add import com.hongchuangtech.HCTInstanceloaderPackage; to the imports at the top of the file
  • Add new HCTInstanceloaderPackage() to the list returned by the getPackages() method
  1. Append the following lines to android/settings.gradle:
    	include ':react-native-instanceloader'
    	project(':react-native-instanceloader').projectDir = new File(rootProject.projectDir, 	'../node_modules/react-native-instanceloader/android')
3. Insert the following lines inside the dependencies block in `android/app/build.gradle`:
  compile project(':react-native-instanceloader')


## Usage

### Load Sub RN App
1. Main RN App
​```javascript
import { NativeModules } from 'react-native';
NativeModules.HCTInstanceloader.startNewInstance({
  androidUrl: 'http://10.0.2.2:8080/water-site/water-site.android.zip', // bundle files w/o any unnecessary directories
  iosUrl: 'http://localhost:8080/water-site/water-site.ios.zip', // bundle files w/o any unnecessary directories
  moduleName: 'WaterSite', // root component name which registed in AppRegistry.registerComponent
  namespace: 'WaterSite', // store local bundle files under this, will use moduleName when not set this value
});
  1. Sub RN App
import { NativeModules } from 'react-native';
NativeModules.HCTInstanceloader.returnMainProcess({});
  1. Example Zip Hierachy (iOS)
HenryMBP:questionnaire henry$ unzip -l questionnaire.ios.zip
Archive:  questionnaire.ios.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
        0  03-13-2018 15:43   assets/
        0  03-13-2018 15:43   assets/js/
        0  03-13-2018 15:43   assets/js/commonView/
        0  03-13-2018 15:43   assets/js/commonView/echarts/
   540418  03-13-2018 15:43   assets/js/commonView/echarts/tpl.html
        0  03-13-2018 15:43   assets/js/questionnaire/
				...
  1465213  03-13-2018 15:43   main.jsbundle
       21  03-13-2018 15:43   main.jsbundle.meta
  1. Example Zip Hierachy (Android)
HenryMBP:questionnaire henry$ unzip -l questionnaire.android.zip
Archive:  questionnaire.android.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
        0  03-13-2018 15:44   drawable-hdpi/
      134  03-13-2018 15:44   drawable-hdpi/node_modules_reactnavigation_src_views_assets_backicon.png
				...
  1457649  03-13-2018 15:44   main.jsbundle
       21  03-13-2018 15:44   main.jsbundle.meta
---------                     -------
  2055977                     43 files

Pass arguments

  1. Pass arguments to Sub RN App
import { NativeModules } from 'react-native';
NativeModules.HCTInstanceloader.startNewInstance({
	androidUrl: 'http://10.0.2.2:8080/water-site/water-site.android.zip', // bundle files w/o any unnecessary directories
	iosUrl: 'http://localhost:8080/water-site/water-site.ios.zip', // bundle files w/o any unnecessary directories
	moduleName: 'WaterSite', // root component name which registed in AppRegistry.registerComponent
	namespace: 'WaterSite', // store local bundle files under this, will use moduleName when not set this value
	initProps: {
			token: '11234123',
			screenProps: { // react-navigation will only take this arguments to its children.
					whatever: 'abcd',
			},
	},
});
  1. Receive arguments from Main RN App (Stateful Comp)
import React from 'react';
import { AppRegistry } from 'react-native';
import { StackNavigator } from 'react-navigation';
const router = StackNavigator({
	// ...
});
class ExampleComp extends React.Component {
	constructor(props) {
		super(props);
		console.log(props);
	}
	render() {
		return router;
	}
}
AppRegistry.registerComponent('WaterSite', () => (props) => <Example {...props} /> );
  1. Receive arguments from Main RN App (Stateless Comp)
import React from 'react';
import { AppRegistry } from 'react-native';
import { StackNavigator } from 'react-navigation';
const router = StackNavigator({
	// ...
});
AppRegistry.registerComponent('WaterSite', () => (props) => {
	console.log(props);
	return router;
});
  1. Return data to Main RN App
import { NativeModules } from 'react-native';
NativeModules.returnMainProcess({
	// anything you want to sendback but function
});
  1. Recive data from Sub RN App
import { NativeModules } from 'react-native';
NativeModules.DeviceEventEmitter.addListener('RNInstanceFinished', data => console.log('receive data from sub rn app!!!', data));
  1. Catch Exception from Sub RN App (Android)
DeviceEventEmitter.addListener('RNInstanceFailed', (msg) => {
	Alert.alert('异常退出', `${msg['PARAMS_MODULE_NAME']}发生了异常...`);
});

Trouble Shooting

  • xcrun: error: unable to find utility "instruments", not a developer tool or in PATH

    Make sure your Command Line Tool for Xcode is out of date.

    And check your Xcode setting.

    https://stackoverflow.com/questions/39778607/error-running-react-native-app-from-terminal-ios

  • [!] The target rntest-tvOSTests is declared twice.

    pod init now will create a wrong Podfile. To make it works, just delete the duplicate item.

  • Make Sure Youre Projects(RN Projects) are bundled with the same RN version.

  • Could not determine java version from '10'. (Can not run react-native run-android)

    Update your Gradle(@4.6) and Android Studio Gradle Plugin(@3.1.1). More info https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration.html#update_gradle

  • /bin/sh: adb: command not found

    Set up your PATH variable for adb. On macOS, you can run export PATH=$PATH:~/Library/Android/sdk/platform-tools/ in Terminal.