React-Native

React-Native 버튼클릭이벤트

김태웜 2021. 1. 5. 22:18

App.js

 


import React from 'react';
import {
  SafeAreaView,
  StyleSheet,
  ScrollView,
  View,
  Text,
  StatusBar,
    TouchableOpacity,
    Button,
} from 'react-native';

import {
  Header,
  LearnMoreLinks,
  Colors,
  DebugInstructions,
  ReloadInstructions,
} from 'react-native/Libraries/NewAppScreen';

const App: () => React$Node = (props) => {
    return (
        /**터치클릭이벤트*/
        /*<TouchableOpacity onPress={() => alert('View 클')}>
            <View>
                <Text>여기를누르면</Text>
            </View>
        </TouchableOpacity>*/
        /**버튼클릭이벤트*/
        <View>
            <Button title="여기를 눌러보세요"
                    onPress={()=>alert('눌렀다')}/>
        </View>
        
    );
}
export default App;

 

View를 이용한 버튼클릭 이벤트 터치클릭이벤트

Button을 이용한 버튼클릭 이벤트 버튼클릭이벤트

'React-Native' 카테고리의 다른 글

React-Native 화면이동3  (0) 2021.01.28
React-Native 화면전환2  (0) 2021.01.26
React-Native CSS  (0) 2021.01.13
React-Native State  (0) 2021.01.12
React-Native 화면전환  (0) 2021.01.08