import React , { useEffect } from 'react' ; import { Alert as AlertOriginal } from 'react-native' ; import { useDialog } from '../context/DialogContext' ; const _alert = window . alert ; const _Alert = { alert : AlertOriginal . alert , prompt : AlertOriginal . prompt } ; export const OverrideSystemDialog = React . memo ( ( ) => { const Dialog = useDialog ( ) ; useEffect ( ( ) => { function alert ( message ? ) { Dialog . show ( undefined , message ) ; } window . alert = alert ; const Alert = { alert : Dialog . show , } ; AlertOriginal . alert = Alert . alert ; return ( ) => { if ( window . alert === alert ) window . alert = _alert ; if ( AlertOriginal . alert === Alert . alert ) AlertOriginal . alert = _Alert . alert ; Dialog . hide ( ) ; } ; } , [ ] ) ; return null ; } ) ; OverrideSystemDialog . displayName = 'OverrideSystemDialog' ;