Use of props
suggest changeOnce 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
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents