Skip to content

Instantly share code, notes, and snippets.

@jkachmar
Created July 22, 2016 20:11
Show Gist options
  • Save jkachmar/a1dd8ffcf4efdddfbbe03c72c9b837e0 to your computer and use it in GitHub Desktop.
Save jkachmar/a1dd8ffcf4efdddfbbe03c72c9b837e0 to your computer and use it in GitHub Desktop.
React Native Tutorial
/**
* Sample React Native App
* https://github.com/facebook/react-native
* @flow
*/
import React from 'react';
import {
AppRegistry,
Image,
StyleSheet,
Text,
View,
} from 'react-native';
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
});
const Greeting = ({ name }) => (
<Text>Hello, {name}!</Text>
);
Greeting.propTypes = { name: React.PropTypes.string.isRequired };
const bananas = {
uri: 'https://upload.wikimedia.org/wikipedia/commons/d/de/Bananavarieties.jpg',
};
const Bananas = ({ pic }) => (
<Image source={pic} style={{ width: 193, height: 110 }} />
);
Bananas.propTypes = { pic: React.PropTypes.object.isRequired };
const HelloWorld = () => (
<View style={styles.container}>
<Greeting name="Alan" />
<Greeting name="Emiliano" />
<Greeting name="Josh" />
<Bananas pic={bananas} />
</View>
);
AppRegistry.registerComponent('HelloWorld', () => HelloWorld);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment