Skip to content

Instantly share code, notes, and snippets.

@ThrowJojo
Created September 19, 2017 04:02
Show Gist options
  • Save ThrowJojo/ab600dc356cd8d5e39189481e9ef4832 to your computer and use it in GitHub Desktop.
Save ThrowJojo/ab600dc356cd8d5e39189481e9ef4832 to your computer and use it in GitHub Desktop.
App file for Counter
// @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