Which code snippet correctly renders a button using the Button core component in React Native?
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: "
<Button title="Click Me" onPress={
() =>alert('Pressed')} />". Button lõi của React Native bắt buộc prop title là chuỗi hiển thị trên nút và nhận hàm xử lý chạm qua onPress; khi bấm, hàm mũi tên chạy và alert hiện hộp thoại chữ Pressed. "
<Button text="Click Me" onClick={
() =>alert('Pressed')} />" mang thói quen từ web: Button không có prop text, và React Native không dùng sự kiện onClick nên bấm sẽ không có gì xảy ra. "
<Button label="Click Me" action={
() =>alert('Pressed')} />" sai vì label và action không phải prop của Button, thiếu title còn gây lỗi. "
<Button caption="Click Me" press={
() =>alert('Pressed')} />" sai vì caption và press đều không có trong API, tên đúng phải là title và onPress.
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