UNPKG

@gluestack-ui/alert-dialog

Version:

A universal headless alert-dialog component for React Native, Next.js & React

17 lines (16 loc) 764 B
import React, { forwardRef } from 'react'; import { AlertDialogContext } from './Context'; import { OverlayAnimatePresence } from './OverlayAnimatePresence'; function AlertDialogBackdrop(StyledAlertDialogBackdrop, AnimatePresence) { return forwardRef(({ children, ...props }, ref) => { const { visible, closeOnOverlayClick, handleClose } = React.useContext(AlertDialogContext); return (<OverlayAnimatePresence visible={visible} AnimatePresence={AnimatePresence}> <StyledAlertDialogBackdrop ref={ref} onPress={() => { closeOnOverlayClick && handleClose(); }} {...props}> {children} </StyledAlertDialogBackdrop> </OverlayAnimatePresence>); }); } export default AlertDialogBackdrop;