From 548d475ddd3a4fcf7daad98b47fb9bd71cea1c8e Mon Sep 17 00:00:00 2001 From: Mentor Palokaj Date: Mon, 15 Nov 2021 09:46:18 +0100 Subject: [PATCH] wrongful looping --- minter/src/components/router.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/minter/src/components/router.js b/minter/src/components/router.js index 9849184..3d38047 100644 --- a/minter/src/components/router.js +++ b/minter/src/components/router.js @@ -27,6 +27,10 @@ function Router() { log( 'Address change' ) + if( timer ) { + log( `cancelling old timer ${ timer }, address: ${ !!address }` ) + clearTimeout( timer ) + } if( !address ) { log( 'No address, setting timer for navigation' ) const timeoutNumber = setTimeout( f => { @@ -34,9 +38,6 @@ function Router() { navigate( '/' ) }, 1000 ) setTimer( timeoutNumber ) - } else { - log( 'Address found, cancelling timer' ) - if( timer ) clearTimeout( timer ) } }, [ address, navigate, timer ] )