Javascript/React-Native

[RN] Alert 사용하는 방법

eulBlue 2024. 10. 14. 15:45

📱테스트 환경

"react": "18.2.0"
"react-native": "0.74.2"

버튼을 눌렀을 때 API 사용후에 '소중한 한표 감사합니다❤️' 창을 띄워주고 싶었는데

React 나 다른 JS 에서 alert('소중한 한표 감사합니다❤️') 이렇게 썼으니까 ..

어차피 RN 도 React 기반이니까 똑같거니 했더니 역시 안됐다 ^^

React Native 에서 Alert 를 사용하는 방법은 다음과같다.

import { Alert } from 'react-native';

Alert.alert('소중한 한표 감사합니다❤️')

이렇게 아주 간단하게 사용할 수 있다.

더 자세한 사용방법은 공식문서에서 확인해볼 수 있는데

확인누르고 콜백받아서 처리를 하거나,

타이틀이나 텍스트도 정해줄 수 있다.

 

Alert · React Native

Launches an alert dialog with the specified title and message.

reactnative.dev

 

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

[RN] Button 만들기  (0) 2024.10.14
[RN] Input 사용하기  (0) 2024.10.14
[RN] React Native Admob 설치  (2) 2024.09.24
[RN] IOS Simulator Error  (1) 2024.09.09
[RN] could not move temporary workspace 에러  (0) 2024.07.31