Skip to content

Instantly share code, notes, and snippets.

@robbiemccorkell
Last active February 13, 2016 03:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save robbiemccorkell/464482c178c3784df9c1 to your computer and use it in GitHub Desktop.
Save robbiemccorkell/464482c178c3784df9c1 to your computer and use it in GitHub Desktop.
React Native - Tappy Button
/**
* @providesModule TappyButtonApp
* @flow
*/
'use strict';
var React = require('react-native/addons');
var {
Bundler,
StyleSheet,
View,
Text,
TouchableHighlight,
} = React;
var TappyButtonApp = React.createClass({
getInitialState() {
return {
score: 0
}
},
render() {
return (
<View style={styles.container}>
<Text style={styles.label}>{'Score: ' + this.state.score}</Text>
<TouchableHighlight
activeOpacity={0.6}
underlayColor={'white'}
onPress={() => this.setState({score: ++this.state.score})}>
<Text style={styles.button}>Tap</Text>
</TouchableHighlight>
</View>
);
}
});
var styles = StyleSheet.create({
container: {
backgroundColor: 'white',
flex: 1,
flexDirection: 'column',
justifyContent: 'center',
alignItems: 'center'
},
button: {
color: 'blue'
},
label: {
marginBottom: 30
}
});
Bundler.registerComponent('TappyButtonApp', () => TappyButtonApp);
module.exports = TappyButtonApp;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment