fengjundev / react-native-remote-update Goto Github PK
View Code? Open in Web Editor NEW使用React-Native实现app热更新的一次实践
使用React-Native实现app热更新的一次实践
0.29版本之后,package注入以及jsbundle注入都是放在ReactApplicaiton中,可是直接重写getBundleAssetName和getJSBundleFile运行app没有效果~
error when executing react-native start, any solution?
│ Running packager on port 8081. │
│ │
│ Keep this packager running while developing on any JS projects. Feel │
│ free to close this tab and run your own packager instance if you │
│ prefer. │
│ │
│ https://github.com/facebook/react-native │
│ │
└────────────────────────────────────────────────────────────────────────────┘
Looking for JS files in
/home/leonard/Descargas/React-Native-Remote-Update-master
ERROR Cannot find module './src/SocketInterface'
{"code":"MODULE_NOT_FOUND"}
Error: Cannot find module './src/SocketInterface'
at Function.Module._resolveFilename (module.js:339:15)
at Function.Module._load (module.js:290:25)
at Module.require (module.js:367:17)
at require (internal/module.js:16:19)
at startSocketInterface (/home/leonard/Descargas/React-Native-Remote-Update-master/node_modules/react-native/packager/react-packager/index.js:119:3)
at createServer (/home/leonard/Descargas/React-Native-Remote-Update-master/node_modules/react-native/packager/react-packager/index.js:95:3)
at Object.exports.middleware (/home/leonard/Descargas/React-Native-Remote-Update-master/node_modules/react-native/packager/react-packager/index.js:20:16)
at getAppMiddleware (/home/leonard/Descargas/React-Native-Remote-Update-master/node_modules/react-native/private-cli/src/server/runServer.js:51:24)
at runServer (/home/leonard/Descargas/React-Native-Remote-Update-master/node_modules/react-native/private-cli/src/server/runServer.js:34:10)
at startServer (/home/leonard/Descargas/React-Native-Remote-Update-master/node_modules/react-native/private-cli/src/server/server.js:141:26)
com.facebook.react.bridge.JSExecutionException: SyntaxError: Unexpected end of script (line 5 in the generated bundle)
at com.facebook.react.bridge.ReactBridge.loadScriptFromFile(Native Method)
at com.facebook.react.bridge.JSBundleLoader$1.loadScript(JSBundleLoader.java:34)
at com.facebook.react.bridge.CatalystInstance$2.run(CatalystInstance.java:138)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31)
at android.os.Looper.loop(Looper.java:136)
at com.facebook.react.bridge.queue.MessageQueueThread$1.run(MessageQueueThread.java:137)
at java.lang.Thread.run(Thread.java:841)
Hi,尝试了用这种热部署的方式,但是中间发现一个问题,如何在调用Bundle以后通过自定义的返回按钮返回到初始化界面呢?尝试了很多方式,只有物理键盘的返回是成功的。
请问下,你这怎么更新图片呢
0.29以后,反射重新加载这个不能使用了,作者有没有更好的方法来重新加载?
method.invoke(mReactInstanceManager,
new JSCJavaScriptExecutor(),
JSBundleLoader.createFileLoader(context, mainBundleFilePath));
在执行这一句时,抛出了一个IllegalAccessException异常,通过log可知是在ReactInstanceManagerImpl类中的下面这个方法中执行了UiThreadUtil.assertOnUiThread();
该方法判断当前不在UI线程,于是抛出异常说“Expected to run on UI thread!”
private void recreateReactContextInBackgroundInner() {
UiThreadUtil.assertOnUiThread();
if (mUseDeveloperSupport && mJSMainModuleName != null) {
if (mDevSupportManager.hasUpToDateJSBundleInCache()) {
// If there is a up-to-date bundle downloaded from server, always use that
onJSBundleLoadedFromServer();
} else if (mJSBundleFile == null) {
mDevSupportManager.handleReloadJS();
} else {
mDevSupportManager.isPackagerRunning(
new DevServerHelper.PackagerStatusCallback() {
@Override
public void onPackagerStatusFetched(final boolean packagerIsRunning) {
UiThreadUtil.runOnUiThread(
new Runnable() {
@Override
public void run() {
if (packagerIsRunning) {
mDevSupportManager.handleReloadJS();
} else {
recreateReactContextInBackgroundFromBundleFile();
}
}
});
}
});
}
return;
}
recreateReactContextInBackgroundFromBundleFile();
}
那么。。。如果运行在UI线程里呢?
之前也想过类似的事情,有考虑过封装成一个独立的模块吗?
看了许久的官方文档,一直都没搞定打包成index.android.bundle文件
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.