Advertisement
Badal_hs_shah

Untitled

Jan 13th, 2023
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React, {useEffect, useState} from 'react';
  2. import {View, Text, TouchableOpacity} from 'react-native';
  3. import ActionSheet from 'react-native-actionsheet';
  4.  
  5. const InvalidVersionAlert = () => {
  6.   const [actionSheetRef, setActionSheetRef] = useState<any>(null);
  7.   const [selected, setSelected] = useState<string>('Select an option');
  8.  
  9.   useEffect(() => {
  10.     console.log('===================>Comes in version Alert');
  11.     showActionSheet();
  12.   }, []);
  13.  
  14.   const showActionSheet = () => {
  15.     actionSheetRef.show();
  16.   };
  17.   console.log('===================>Comes in version Alert');
  18.  
  19.   const handlePress = (index: number) => {
  20.     const options = ['Option 1', 'Option 2', 'Option 3'];
  21.     setSelected(options[index]);
  22.   };
  23.  
  24.   return (
  25.     <View>
  26.       <ActionSheet
  27.         ref={o => setActionSheetRef(o)}
  28.         title={'Select an option'}
  29.         options={['Option 1', 'Option 2', 'Option 3', 'Cancel']}
  30.         cancelButtonIndex={3}
  31.         onPress={handlePress}
  32.       />
  33.     </View>
  34.   );
  35. };
  36.  
  37. export default InvalidVersionAlert;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement