Skip to content

Instantly share code, notes, and snippets.

@jenbennings
Created January 12, 2016 06:42
Show Gist options
  • Save jenbennings/c079863351420c4301d2 to your computer and use it in GitHub Desktop.
Save jenbennings/c079863351420c4301d2 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,
Image,
View,
} = React;
var Firebase = require('firebase');
var tramsimulator = React.createClass({
componentWillMount: function() {
this.firebaseRef = new Firebase("https://ReactFireTodoApp.firebaseio.com/items/");
this.firebaseRef.on("child_changed", function(dataSnapshot) {
this.setState({
dings: this.dings
});
}.bind(this));
},
render: function() {
return (
<View style={styles.container}>
<Image style={styles.header} source={require('./logo.png')} />
<View style={{width: 100, height: 100, padding: 20, backgroundColor: 'red', borderRadius: 50}}>
</View>
<Text style={styles.instructions}>
{ this.state.items } dings have been dung so far
</Text>
</View>
);
}
});
var styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'space-between',
alignItems: 'center',
backgroundColor: '#6BBE53',
},
header: {
width: 200
},
welcome: {
fontSize: 20,
textAlign: 'center',
margin: 10,
},
instructions: {
textAlign: 'center',
color: 'white',
marginBottom: 5,
},
});
AppRegistry.registerComponent('tramsimulator', () => tramsimulator);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment