If a developer wants to integrate a custom native module into a React Native application, what ensures that this module will work effectively with the existing architecture?

4 phương ánCó giải thích

Các phương án trả lời

Chọn một phương án
Lời giảiChọn phương án để mở
Đáp án đúng: "The native module needs to be integrated into the startup of the Native Thread to ensure it is always packaged and ready.". Native Module là mã native nên sống ở phía native: nó phải được đóng gói vào ứng dụng và đăng ký lúc ứng dụng khởi động (Android thêm Package vào getPackages trong MainApplication, iOS dùng RCT_EXPORT_MODULE), để khi JavaScript gọi thì phía native đã có sẵn module đó. Đây chính là ý tích hợp vào quá trình khởi động phía native. "The native module must be pre-compiled in the JavaScript Thread to be compatible with the bridge." sai vì JavaScript Thread chỉ chạy mã JavaScript, không biên dịch mã Java hay Objective-C; mã native được biên dịch lúc build bằng Gradle hoặc Xcode. "The native module must have its layout calculated first by the Shadow Thread to ensure an accurate interface." sai vì Shadow Thread chỉ tính bố cục cho thành phần giao diện; module không có giao diện thì không cần bố cục. "The native module only needs to be added without requiring integration with any thread." sai vì module không được đăng ký thì React Native không biết nó tồn tại và lời gọi từ JavaScript sẽ thất bại.

Cùng chương 1

Xuất hiện trong 1 bộ đề