props trong React Native là gì?

{{FormatNumbertoThousand(model.total_like)}} lượt thích
444 lượt xem
  • Các thuộc tính của các React Native component được phát âm đơn giản là props.
  • Trong React Native, hầu hết các component có thể được tùy chỉnh tại thời điểm tạo với các tham số khác nhau. Các thông số này được gọi là props.
  • Chúng là bất biến, và chúng không thể thay đổi.
import React, { Component } from 'react';
import {
   Platform,
   StyleSheet,
   Image,
   Text,
   View
} from 'react-native';

export default class App extends Component<{}> {
   render() {
      let imagePath = { uri: 'https://facebook.github.io/react native/img/header_logo.png'};
      return (
         <View style={styles.container}>
            <Text style={styles.welcome}>Welcome to React Native!</Text>
            <Image source={imagePath} style={{width: 250, height: 250}} />
         </View>
      );
   }
} 

const styles = StyleSheet.create({
   container: {
      flex: 1,
      justifyContent: 'center',
      alignItems: 'center',
      backgroundColor: '#a7a6a9',
   },
   welcome: {
      fontSize: 30,
      textAlign: 'center',
      margin: 20,
   }
});

PhongvanIT.com

{{login.error}}