Created
January 29, 2020 23:00
-
-
Save ozcanzaferayan/c57aff4302bd182e6d04e136466b29d1 to your computer and use it in GitHub Desktop.
Mobx with functional component
This file contains hidden or 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
import React from 'react'; | |
import { Button, Text, SafeAreaView } from 'react-native'; | |
import { observable } from 'mobx'; | |
import { observer } from 'mobx-react'; | |
const store = observable({ count: 0 }); | |
const LoginScreen = observer(() => { | |
handleInc = () => store.count++; | |
handleDesc = () => store.count--; | |
return ( | |
<SafeAreaView> | |
<Button title="+" onPress={handleInc} /> | |
<Button title="-" onPress={handleDesc} /> | |
<Text style={{ alignSelf: 'center' }}>{store.count}</Text> | |
</SafeAreaView> | |
) | |
}); | |
export default LoginScreen; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment