Skip to content

Instantly share code, notes, and snippets.

@fadhelutama
Created October 23, 2019 16:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fadhelutama/cc8c19ec23dfb546218921dfd0029706 to your computer and use it in GitHub Desktop.
Save fadhelutama/cc8c19ec23dfb546218921dfd0029706 to your computer and use it in GitHub Desktop.
cara penggunaan usestate
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