@@ -4,27 +4,26 @@ import { cloneElement } from 'react';
44import { throttle } from 'lodash' ;
55import { StyleSheet , View } from 'react-native' ;
66
7- import { renderToPortal } from '../views/Overlay/RootPortal' ;
7+ import { enterPortal } from '../views/Overlay/RootPortal' ;
88
99import type { PortalManager } from '../views/Overlay/RootPortal' ;
1010
1111export const FULLWINDOW_OVERLAY_PORTAL = 'Root-FullWindowOverlay' ;
1212
13- type IOverlayContentRender = ( closeOverlay : ( ) => void ) => ReactElement ;
1413export const showOverlay = throttle (
15- ( renderOverlay : IOverlayContentRender ) => {
14+ ( renderOverlay : ( closeOverlay : ( ) => void ) => ReactElement ) => {
1615 let portal : PortalManager | null ;
1716 const closeOverlay = ( ) => {
1817 portal ?. destroy ( ) ;
1918 portal = null ;
2019 } ;
20+ const content = (
21+ < View pointerEvents = "box-none" style = { StyleSheet . absoluteFill } >
22+ { renderOverlay ( closeOverlay ) }
23+ </ View >
24+ ) ;
2125 setTimeout ( ( ) => {
22- const content = (
23- < View pointerEvents = "box-none" style = { StyleSheet . absoluteFill } >
24- { renderOverlay ( closeOverlay ) }
25- </ View >
26- ) ;
27- portal = renderToPortal ( FULLWINDOW_OVERLAY_PORTAL , content ) ;
26+ portal = enterPortal ( FULLWINDOW_OVERLAY_PORTAL , content ) ;
2827 } ) ;
2928 return closeOverlay ;
3029 } ,
@@ -36,14 +35,12 @@ export const showOverlay = throttle(
3635) ;
3736
3837export const showDialog = ( render : ReactElement ) =>
39- showOverlay (
40- //
41- ( closeOverlay ) =>
42- cloneElement ( render , {
43- onClose : ( ) => {
44- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
45- render . props . onClose ?.( ) ;
46- closeOverlay ( ) ;
47- } ,
48- } ) ,
38+ showOverlay ( ( onClose ) =>
39+ cloneElement ( render , {
40+ onClose : ( ) => {
41+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
42+ render . props . onClose ?.( ) ;
43+ onClose ( ) ;
44+ } ,
45+ } ) ,
4946 ) ;
0 commit comments