import React, { Fragment} from 'react'; import ReactNativeComponentTree, { View, ViewStyle, StyleProp, } from 'react-native'; import { PaneOverlayStyles } from './PaneOverlay.styles'; interface IPaneOverlayProps { /** * Content of the overlay */ children: React.ReactElement; /** * If true, the overlay is visible */ isVisible: boolean; /** * Style for the backdrop */ backdropStyle?: StyleProp; /** * Style of the actual overlay */ overlayStyle?: StyleProp; /** * Callback when user touches the backdrop */ onBackdropPress:()=> void; } const PaneOverlay = (props: IPaneOverlayProps) => { return ( {props.isVisible && ( { //check if we are clicking ourselves or a different component if ( String(ReactNativeComponentTree.findNodeHandle(event.currentTarget)) === String(event.nativeEvent.target) ) { if(props.onBackdropPress) { props.onBackdropPress(); } } }}> {props.children} )} ); }; export default PaneOverlay;