@@ -71,7 +71,7 @@ const FlutterwaveCheckout: React.FC<FlutterwaveCheckoutProps> = function Flutter
7171 } ) . start ( ) ;
7272 } , [ ] ) ;
7373
74- const animateOut = React . useCallback ( ( ) => {
74+ const animateOut = React . useCallback ( ( ) : Promise < void > => {
7575 return new Promise ( resolve => {
7676 Animated . timing ( animation . current , {
7777 toValue : 0 ,
@@ -106,19 +106,20 @@ const FlutterwaveCheckout: React.FC<FlutterwaveCheckoutProps> = function Flutter
106106 animateOut ( ) . then ( onAbort ) ;
107107 } , [ onAbort , animateOut ] ) ;
108108
109- const handleNavigationStateChange = React . useCallback ( ( ev : WebViewNavigation ) => {
109+ const handleNavigationStateChange = React . useCallback ( ( ev : WebViewNavigation ) : boolean => {
110110 // cregex to check if redirect has occured on completion/cancel
111111 const rx = / \/ f l u t t e r w a v e \. c o m \/ r n - r e d i r e c t / ;
112112 // Don't end payment if not redirected back
113113 if ( ! rx . test ( ev . url ) ) {
114- return
114+ return true ;
115115 }
116116 // dismiss modal
117117 animateOut ( ) . then ( ( ) => {
118118 if ( onRedirect ) {
119119 onRedirect ( getRedirectParams ( ev . url ) )
120120 }
121121 } ) ;
122+ return false ;
122123 } , [ onRedirect ] ) ;
123124
124125 const doAnimate = React . useCallback ( ( ) => {
@@ -169,7 +170,7 @@ const FlutterwaveCheckout: React.FC<FlutterwaveCheckoutProps> = function Flutter
169170 startInLoadingState = { true }
170171 scalesPageToFit = { true }
171172 javaScriptEnabled = { true }
172- onNavigationStateChange = { handleNavigationStateChange }
173+ onShouldStartLoadWithRequest = { handleNavigationStateChange }
173174 renderError = { ( ) => < FlutterwaveCheckoutError hasLink = { ! ! link } onTryAgain = { handleReload } /> }
174175 renderLoading = { ( ) => < FlutterwaveCheckoutLoader /> }
175176 />
0 commit comments