react native 热更新(不重启应用)

下载完 更新文件后调用此方法 其中JS_BUNDLE_LOCAL_PATH 为下载完的路径

private void reLoadReact() {

ReactInstanceManager mReactInstanceManager=getReactInstanceManager();

try {

Class RIManagerClazz = mReactInstanceManager.getClass();

Method method = RIManagerClazz.getDeclaredMethod("recreateReactContextInBackground",

JavaScriptExecutor.Factory.class, JSBundleLoader.class);

method.setAccessible(true);

method.invoke(mReactInstanceManager,new JSCJavaScriptExecutor.Factory(JSCConfig.EMPTY.getConfigMap()),

JSBundleLoader.createFileLoader(JS_BUNDLE_LOCAL_PATH));

} catch (Exception e) {

e.printStackTrace();

}

}

你可能感兴趣的:(react native 热更新(不重启应用))