When should you choose a more complex data management solution instead of just using simple JavaScript variables?
4 phương ánCó giải thích
Các phương án trả lời
Chọn một phương ánLời giảiChọn phương án để mở
Đáp án đúng: "When the application becomes more complex (e.g., multiple components need to access and modify the same data).". Biến JavaScript thường không khiến giao diện render lại khi đổi giá trị và khó chia sẻ an toàn giữa nhiều component; khi ứng dụng phức tạp lên và nhiều component cùng đọc, cùng sửa một dữ liệu, ta cần giải pháp quản lý state như Context, Redux, Zustand hay MobX để có một nguồn dữ liệu duy nhất và cập nhật giao diện đồng bộ. "When the application needs to store more than 10,000 records." không phải tiêu chí: lưu số lượng lớn bản ghi là việc của cơ sở dữ liệu cục bộ như SQLite, Realm, không phụ thuộc một ngưỡng cố định. "When you want to reduce the load on the backend API." liên quan tới cache, phân trang hay gộp yêu cầu nhiều hơn là tổ chức dữ liệu trong app. "When you need to synchronize data between multiple devices." đòi hỏi backend hoặc dịch vụ đồng bộ như Firebase, vì giải pháp quản lý state cục bộ không tự đồng bộ dữ liệu giữa các thiết bị.
Cùng chương 6
Given the following Redux reducer and action in a React Native application, what will be the value of the state after dispatching the increment action? // Reducer const counterReducer = (state = { count: 0 }, action) => { switch (action.type) { case 'INCREMENT': return { ...state, count: state.count + 1 }; default: return state; } }; // Action const increment = () => ({ type: 'INCREMENT' });Có lời giảiCâu hỏiWhat is a key difference between useReducer and useState in React Native?Có lời giảiCâu hỏiWhich of the following is not an option to manage data throughout a React Native app?Có lời giảiCâu hỏiCả 13 câu của chủ đề13 câu