<View>
, <Button>
, <Text>
để xây dựng giao diện người dùng.Lớp Kiến Trúc | Chức Năng Chính | Công Nghệ/Đặc Điểm |
---|---|---|
App Layer | Viết app, xử lý logic kinh doanh | React components, JavaScript/TypeScript |
React Runtime + JSI | Chạy JavaScript, kết nối trực tiếp đến native | Hermes, JavaScriptCore, JSI, TurboModules |
Rendering & Bridge | Chuyển đổi component thành native views | Fabric Renderer, Yoga Layout Engine |
Native Platform Layer | Xử lý phần cứng và hệ thống gốc | Kotlin/Java (Android), Swift/Obj-C (iOS) |
onPress
) được gọi và logic nghiệp vụ được thực thi.// JSI bridge exposes the button event handlerinstallJSFunction(runtime, "handlePress", []() { jsRuntime.invoke("handlePress"); // Gọi trực tiếp hàm JS});
void onTouchEvent(ViewID id) { if (id == buttonViewID) { auto event = createPressEvent(); dispatchEventToJSI(event); // Truyền sự kiện đến JS qua JSI }}
void reconcileChanges(ReactTree newTree) { auto diff = diffTrees(oldTree, newTree); applyNativeChanges(diff); // Cập nhật giao diện}
fun updateNativeView(componentId: String, newProps: Props) { when (componentId) { "TextView" -> textView.text = newProps.text "ButtonView" -> button.title = newProps.title }}