Computer >> Hướng Dẫn Máy Tính >  >> Lập Trình >> JavaScript

Các core component quan trọng của React Native


Các core component quan trọng nhất trong React Native:

React Native component Android Native View iOS Native View Web Browser Mô tả
View - <View> <ViewGroup> <UIView> <div> Container cốt lõi, hỗ trợ flexbox layout, xử lý touch.
Text - <Text> <TextView> <UITextView> <p> Hiển thị văn bản, hỗ trợ styling và touch event.
Image - <Image> <ImageView> <UIImageView> <img> Hiển thị hình ảnh.
ScrollView - <ScrollView> <ScrollView> <UIScrollView> <div> Container cuộn chứa các component/view.
TextInput - <TextInput> <EditText> <UITextField> <input type="text"> Ô nhập liệu văn bản từ người dùng.

Ví dụ

Import các component:

import { View, Text, Image, ScrollView, TextInput } from 'react-native';

View chứa Text, Image:


    Inside View Container
    

ScrollView làm parent chứa View, Text, Image, TextInput:

import React from 'react';
import { View, Text, Image, ScrollView, TextInput } from 'react-native';

const App = () => {
    return (
        
            Welcome to TutorialsPoints!
            
                Inside View Container
                
            
            
        
    );
}
export default App;

Kết quả

Các core component quan trọng của React Native