Skip to content

Instantly share code, notes, and snippets.

@VonD
Created April 20, 2015 13:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save VonD/a530d21a53499a085080 to your computer and use it in GitHub Desktop.
Save VonD/a530d21a53499a085080 to your computer and use it in GitHub Desktop.
/**
* Sample React Native App
* https://github.com/facebook/react-native
*/
'use strict';
var React = require('react-native');
var {
AppRegistry,
StyleSheet,
Text,
View,
Image,
CameraRoll
} = React;
var TestImagesLoadingTime = React.createClass({
getInitialState: function(){
return {};
},
componentDidMount: function(){
CameraRoll.getPhotos({first: 1}, function(data){
if (!data.edges.length) return;
this.setState({
picture: data.edges[0].node.image.uri
});
}.bind(this), console.log);
},
render: function() {
return (
<View style={styles.container}>
<Text style={styles.welcome}>
Welcome to React Native!
</Text>
<Text style={styles.instructions}>
To get started, edit index.ios.js
</Text>
<Text style={styles.instructions}>
Press Cmd+R to reload,{'\n'}
Cmd+Control+Z for dev menu
</Text>
{
this.state.picture &&
<Image
style={ styles.pic }
source={ {uri: this.state.picture} }
>
<Text style={ styles.loading }>rendering { this.state.picture }…</Text>
</Image>
}
</View>
);
}
}); //source={ {uri: "http://www.counterpunch.org/wp-content/dropzone/2014/09/KillingTrayvons_Cover1-291x450.jpg"} }
var styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
welcome: {
fontSize: 20,
textAlign: 'center',
margin: 10,
},
instructions: {
textAlign: 'center',
color: '#333333',
marginBottom: 5,
},
loading: {
fontSize: 12,
color: 'grey'
},
pic: {
height: 200,
width: 200,
borderWidth: 1,
borderColor: 'red',
justifyContent: 'center',
alignItems: 'center'
}
});
AppRegistry.registerComponent('TestImagesLoadingTime', () => TestImagesLoadingTime);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment