Created
September 19, 2017 04:02
-
-
Save ThrowJojo/ab600dc356cd8d5e39189481e9ef4832 to your computer and use it in GitHub Desktop.
App file for Counter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// @flow | |
import React, { Component } from "react"; | |
import { Text, View, Button, StyleSheet } from "react-native"; | |
import CounterStore from "./stores/CounterStore"; | |
import Counter from "./components/Counter"; | |
import { Provider, inject } from "mobx-react"; | |
const counterStore = new CounterStore(); | |
export default class App extends Component { | |
render() { | |
return ( | |
<Provider counterStore={counterStore}> | |
<Content /> | |
</Provider> | |
); | |
} | |
} | |
@inject("counterStore") | |
class Content extends Component { | |
render() { | |
return ( | |
<View style={Styles.container}> | |
<Counter /> | |
<Button | |
title="Increase" | |
onPress={() => this.props.counterStore.increase()} | |
/> | |
<Button | |
title="Decrease" | |
onPress={() => this.props.counterStore.decrease()} | |
/> | |
</View> | |
); | |
} | |
} | |
let Styles = StyleSheet.create({ | |
container: { | |
flex: 1, | |
backgroundColor: "white", | |
justifyContent: "center", | |
alignItems: "center" | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment