-
<react-native> Button, alert, ...app/react-native 2022. 4. 9. 17:08반응형
alert 메서드
import React from 'react' import { Alert, SafeAreaView, Button } from 'react-native' export default function App() { return( <SafeAreaView> <Button title='Home' onPress={() => Alert.alert('home pressed.','message')} /> </SafeAreaView> ) }
실행결과
터치블 코어 컴포넌트
import React from 'react' import { Alert, SafeAreaView, Button } from 'react-native' import { TouchableOpacity, TouchableHighlight, Text } from 'react-native' const onPress = () => Alert.alert('home pressed.', 'maessage') export default function App() { return( <SafeAreaView> <Button title='Home' onPress={onPress} /> <TouchableOpacity onPress={onPress}> <Text> TouchableOpacity </Text> </TouchableOpacity> <TouchableHighlight onPress={onPress}> <Text> ouchableHighlight </Text> </TouchableHighlight> </SafeAreaView> ) }
실행결과
여기서는 확인 불가하나
실행해보면 두가지가 효과가 다른다는 것이 확인 가능하다.
TextInput 코어 컴포넌트
import React from 'react' import { Alert, SafeAreaView, Button } from 'react-native' import { TouchableOpacity, TouchableHighlight, Text } from 'react-native' import {TextInput} from 'react-native' const onPress = () => Alert.alert('home pressed.', 'maessage') export default function App() { return( <SafeAreaView> <Button title='Home' onPress={onPress} /> <TouchableOpacity onPress={onPress}> <Text> TouchableOpacity </Text> </TouchableOpacity> <TouchableHighlight onPress={onPress}> <Text> ouchableHighlight </Text> </TouchableHighlight> <TextInput placeholder="enter yourname" onChangeText={(text: string) => console.log(text)} onFocus={() => console.log('onFocus')} onBlur={() => console.log('onBlur')} onEndEditing={() => console.log('onEndEditing')} /> </SafeAreaView> ) }
실행결과
>>>
...
log 찍힌거 확인!
오늘 할 일 끄읏!~~~~
반응형'app > react-native' 카테고리의 다른 글
<react-native>view 컴포넌트와 css 박스 모델/자원과 아이콘 사용하기 (0) 2022.04.11 <react-native> faker / error 확인 (1) 2022.04.09 <react-native> style 속성과 styleSheet API ... (0) 2022.04.09 react-native를 시작하면서/window 개발환경 설정/오류 해결_2 (0) 2022.04.06 react-native를 시작하면서/window 개발환경 설정/오류 해결_1 (0) 2022.04.06