Copyimport { AlertDialog } from "native-base";
Playgroundfunction AlertDialogComponent() {const [isOpen, setIsOpen] = React.useState(false);const onClose = () => setIsOpen(false);const cancelRef = React.useRef();return <Center><AlertDialog leastDestructiveRef={cancelRef} isOpen={isOpen} onClose={onClose} motionPreset={"fade"}><AlertDialog.Content><AlertDialog.Header fontSize="lg" fontWeight="bold">Delete Customer</AlertDialog.Header><AlertDialog.Body>Are you sure? You can't undo this action afterwards.</AlertDialog.Body><AlertDialog.Footer><Button ref={cancelRef} onPress={onClose}>Cancel</Button><Button colorScheme="red" onPress={onClose} ml={3}>Delete</Button></AlertDialog.Footer></AlertDialog.Content></AlertDialog><Button colorScheme="danger" onPress={() => setIsOpen(!isOpen)}>Delete Customer</Button></Center>;}function Example() {return <NativeBaseProvider><Center flex={1}><AlertDialogComponent /></Center></NativeBaseProvider>;}
Playgroundfunction AlertDialogComponent() {const [isOpen, setIsOpen] = React.useState(false);const onClose = () => setIsOpen(false);const cancelRef = React.useRef();return <Center><AlertDialog motionPreset="fade" leastDestructiveRef={cancelRef} onClose={onClose} isOpen={isOpen} isCentered><AlertDialog.Content><AlertDialog.CloseButton /><AlertDialog.Header>Discard Changes?</AlertDialog.Header><AlertDialog.Body>Are you sure you want to discard all of your notes? 44 words will bedeleted.</AlertDialog.Body><AlertDialog.Footer><Button ref={cancelRef} onPress={onClose}>No</Button><Button colorScheme="red" ml={3}>Yes</Button></AlertDialog.Footer></AlertDialog.Content></AlertDialog><Button onPress={() => setIsOpen(!isOpen)}>Discard</Button></Center>;}function Example() {return <NativeBaseProvider><Center flex={1}><AlertDialogComponent /></Center></NativeBaseProvider>;}