What is the main function of Redux in data management?
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: "It provides a store object to maintain application state and notify components of state changes". Redux giữ toàn bộ state chung của ứng dụng trong một store duy nhất; muốn đổi state phải dispatch một action, reducer là hàm thuần nhận state cũ cùng action rồi trả state mới, sau đó store thông báo cho các component đã đăng ký (qua useSelector hoặc connect của react-redux) để chúng render lại. "It manages CSS styles" sai vì style do StyleSheet hoặc thư viện styling đảm nhận. "It allows for server-side rendering" sai vì render phía máy chủ là việc của framework như Next.js, Redux chỉ quản lý state. "It provides a custom database for large datasets" sai vì store nằm trong bộ nhớ, không phải cơ sở dữ liệu; dữ liệu lớn cần lưu bền thì dùng SQLite hay Realm.
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