From 0540a65fd844df12ccb76d9d58dd14438e205189 Mon Sep 17 00:00:00 2001 From: Eugene Shepel Date: Wed, 4 Jan 2023 18:19:44 +0200 Subject: [PATCH] fix blinking modal on modal close --- src/modal.tsx | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/modal.tsx b/src/modal.tsx index f6b478e..04146cc 100644 --- a/src/modal.tsx +++ b/src/modal.tsx @@ -672,19 +672,17 @@ export class ReactNativeModal extends React.Component { if (this.props.isVisible) { this.open(); } else { + // animation is done here, so just need to actualize state + // if set state by 1 prop (showContent: false and then isVisible: false), + // then when showContent set false, render is called with isVisible: true + // and this leads to blinking when user closes modal (it is seen on ios devices) this.setState( { showContent: false, + isVisible: false, }, () => { - this.setState( - { - isVisible: false, - }, - () => { - this.props.onModalHide(); - }, - ); + this.props.onModalHide(); }, ); }