Skip to content

Instantly share code, notes, and snippets.

@sharathprabhal
Created February 10, 2016 23:37
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 sharathprabhal/a21dd6aadcd21454b2b4 to your computer and use it in GitHub Desktop.
Save sharathprabhal/a21dd6aadcd21454b2b4 to your computer and use it in GitHub Desktop.
module.exports = React.createClass({
displayName: 'ImageTester',
getInitialState() {
return {
showImage: false
};
},
render() {
var imageSrc = 'http://www.eatornotapp.com/img/Home.png?cBuster' + Math.random();
var image;
var buttonLabel;
if (!this.state.showImage) {
buttonLabel = 'Show Image';
image = (
<View
style={{
height: 534,
width: 300,
backgroundColor: '#CCC'
}}
>
</View>
);
} else {
buttonLabel = 'Hide Image';
image = (
<Image
style={{
height: 534,
width: 300,
backgroundColor: '#CCC'
}}
source={{
uri: imageSrc
}} />
);
}
return (
<View
style={{
flex: 1,
alignItems: 'center',
justifyContent: 'center',
}}
>
<TouchableOpacity
style={{
padding: 30
}}
onPress={() => {
this.setState({showImage: !this.state.showImage});
}}
>
<Text>{buttonLabel}</Text>
</TouchableOpacity>
{image}
</View>
);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment