[英]React Native - Bridge Android Native to React Native get Slow Performance
I'm new in bridging Native (Android) to React Native.我是将 Native (Android) 桥接到 React Native 的新手。
I want to send a lot of data from Android Native to React Native but get performance issues (slow).我想从 Android Native 向 React Native 发送大量数据,但遇到性能问题(慢)。
Here my example code :这是我的示例代码:
Android Native (using callback): Android 原生(使用回调):
for(int i = 0 ; i < 10000000000000 ; i++){
this.dispatchEvent("MyEvent","hello this is my message");
}
React Native :反应本机:
var myFunction = (tags) => {
console.log("Message :"+tags);
}
RNTry.on("MyEvent", myFunction);
What result i get :我得到什么结果:
My Question :我的问题 :
How to send a lot of data (real time) from Android Native to React Native without get React Native UI freeze/lag?
如何在不让 React Native UI 冻结/滞后的情况下从 Android Native 向 React Native 发送大量数据(实时)?
try to send events from android to react尝试从 android 发送事件以做出反应
private void sendEvent(ReactContext reactContext,
String eventName,
@Nullable WritableMap params) {
reactContext
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
.emit(eventName, params);
}
read about it https://reactnative.dev/docs/native-modules-android阅读它https://reactnative.dev/docs/native-modules-android
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.