In React Native, which of the following are correct characteristics when using Class Components?
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 gồm hai ý: "Must inherit from Component imported from the react library." và "Needs to use the render() method to return the interface.". Class component được khai báo bằng class TenComponent extends Component, trong đó Component import từ gói react, và bắt buộc có phương thức render() trả về JSX mô tả giao diện; state nằm ở this.state và được cập nhật qua this.setState, props đọc qua this.props. "Does not need to import Text from react-native." sai: muốn hiển thị chữ thì vẫn phải import Text từ react-native, bất kể component viết bằng class hay bằng hàm, vì chữ trần không được đặt trực tiếp trong View. "Can be declared using the same syntax as Function Components." sai vì function component là một hàm nhận props và trả JSX, còn class component dùng cú pháp class với extends và render(), hai cách khai báo khác hẳn nhau.
Cùng chương 2
A View component can be nested inside other views. Select the correct option.Có lời giảiCâu hỏiWhich component is the foundation for all React Native components and provides the base functionality for rendering elements to the screen?Có lời giảiCâu hỏiWhich keyword is used to extend a component from a base component?Có lời giảiCâu hỏiCả 54 câu của chủ đề54 câu