Use of props

suggest change

Once setup is complete, copy the code below into index.android.js or index.ios.js.

import React, { Component } from 'react';
import { AppRegistry, Text, View } from 'react-native';

class Greeting extends Component {
  render() {
    return (
      <Text>Hello {this.props.name}!</Text>
    );
  }
}

class LotsOfGreetings extends Component {
  render() {
    return (
      <View style={{alignItems: 'center'}}>
        <Greeting name='Rexxar' />
        <Greeting name='Jaina' />
        <Greeting name='Valeera' />
      </View>
    );
  }
}

AppRegistry.registerComponent('LotsOfGreetings', () => LotsOfGreetings);

Props make a component generic. A button component, for example, can take different props so you can place that same button anywhere in a view.

source: Props-React Native

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents