Created
October 23, 2019 16:17
-
-
Save fadhelutama/cc8c19ec23dfb546218921dfd0029706 to your computer and use it in GitHub Desktop.
cara penggunaan usestate
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
import React, { useState } from 'react'; | |
import { StyleSheet, Text, View, Button } from 'react-native'; | |
export default function App() { | |
const [count, setCount] = useState(0); | |
return ( | |
<View style={styles.container}> | |
<Text>You clicked {count} times.</Text> | |
<Button | |
onPress={() => setCount(count + 1)} | |
title="Click me" | |
color="red" | |
accessibilityLabel="Click this button to increase count" | |
/> | |
</View> | |
); | |
} | |
const styles = StyleSheet.create({ | |
container: { | |
flex: 1, | |
justifyContent: 'center', | |
alignItems: 'center', | |
backgroundColor: '#F5FCFF' | |
}, | |
welcome: { | |
fontSize: 20, | |
textAlign: 'center', | |
margin: 10 | |
}, | |
instructions: { | |
textAlign: 'center', | |
color: '#333333', | |
marginBottom: 5 | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment