Describe a situation where a developer would benefit from creating a Native Module for a React Native app.

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: "A developer needs to integrate fingerprint authentication, which requires access to native device APIs for both iOS and Android. By implementing this as a Native Module, they can efficiently leverage platform-specific APIs to provide secure authentication without compromising performance.". Native Module đáng làm khi ứng dụng cần một khả năng của nền tảng mà JavaScript không tự truy cập được; xác thực vân tay phải gọi API sinh trắc học riêng của từng hệ điều hành (BiometricPrompt trên Android, LocalAuthentication trên iOS), nên viết module gốc rồi đưa ra một hàm chung cho JavaScript là lựa chọn hợp lý. Tình huống "center-align text in their app" sai vì căn giữa chữ chỉ cần textAlign: 'center' trong style. Tình huống "add a button with a color change on press" sai vì Pressable hay TouchableOpacity cùng state đã làm được, không cần mã gốc. Tình huống "to handle static images, even though no platform-specific functionality is needed" sai vì component Image với require đã hiển thị ảnh tĩnh, và chính mô tả cho biết không cần tính năng riêng của nền tảng.

Cùng chương 1

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