반응형
Notice
Recent Posts
Recent Comments
Link
«   2023/09   »
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
Archives
Today
Total
관리 메뉴

둘에서 하나로....

[react native] 카운터 앱 본문

프로그래밍

[react native] 카운터 앱

서기㏇ 2021. 2. 18. 20:00
반응형
import { StatusBar } from 'expo-status-bar';
import React, { useState } from 'react';
import { StyleSheet, Text, View, Button } from 'react-native';


export default function App() {

  const [cnt, setCnt] = useState(10); 



  return (
    <View style={styles.container}>
      <Text style={styles.assa}>헬로우 리엑트 네이티브</Text>
      <Text style={styles.cnt}>{cnt}</Text>
      <Button title="더하기" onPress={  () => setCnt(cnt+1)  }></Button>
      <Button title="빼기" onPress={  () => setCnt(cnt-1)  }></Button>
      <StatusBar style="auto" />
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#fff',
    alignItems: 'center',
    justifyContent: 'center',
  },
  assa:{
    color:'#f00', 
    fontSize:20, 
  },
  cnt:{
    fontSize:50, 
    marginTop:20, 
  }

});
반응형
Comments