From 5e1712fbae61dd065f7fbc89df4ddd1235e7dfe7 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Raynaud Date: Thu, 30 Nov 2023 14:44:49 +0100 Subject: [PATCH 1/2] Fix infinite loop in explorer This problems occurred when switchin aggregator and was due to infinite loops in useEffect(). The fix is to add 'eslint-disable-line' directive. --- mithril-explorer/src/app/page.js | 17 ++++++++++------- mithril-explorer/src/app/registrations/page.js | 2 +- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/mithril-explorer/src/app/page.js b/mithril-explorer/src/app/page.js index 609960580b0..c80970a2c29 100644 --- a/mithril-explorer/src/app/page.js +++ b/mithril-explorer/src/app/page.js @@ -60,18 +60,21 @@ export default function Explorer() { } dispatch(updatePoolsForAggregator(selectedAggregator)); - }, [selectedAggregator, router, searchParams, dispatch]); + }, [selectedAggregator]); // eslint-disable-line react-hooks/exhaustive-deps // Allow navigation to work (previous, next) useEffect(() => { - if (isUpdatingAggregatorInUrl) { - setIsUpdatingAggregatorInUrl(false); - } else { - const aggregatorInUrl = searchParams.get("aggregator"); + function allowNavigation() { + if (isUpdatingAggregatorInUrl) { + setIsUpdatingAggregatorInUrl(false); + } else { + const aggregatorInUrl = searchParams.get("aggregator"); - dispatch(selectAggregator(aggregatorInUrl)); + dispatch(selectAggregator(aggregatorInUrl)); + } } - }, [searchParams, dispatch, isUpdatingAggregatorInUrl]); + allowNavigation(); + }, [searchParams]); // eslint-disable-line react-hooks/exhaustive-deps return ( diff --git a/mithril-explorer/src/app/registrations/page.js b/mithril-explorer/src/app/registrations/page.js index 925a26a9863..f9354911fc5 100644 --- a/mithril-explorer/src/app/registrations/page.js +++ b/mithril-explorer/src/app/registrations/page.js @@ -90,7 +90,7 @@ export default function Registrations() { } else { setCurrentError(error); } - }, [searchParams, dispatch]); + }, [searchParams]); // eslint-disable-line react-hooks/exhaustive-deps function getNoRegistrationsMessage() { if (currentEpoch === registrationEpoch) { From 8343f6fdeb1bfde8622d79656e6f26205380e1d2 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Raynaud Date: Thu, 30 Nov 2023 14:45:20 +0100 Subject: [PATCH 2/2] Update explorer version --- mithril-explorer/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mithril-explorer/package.json b/mithril-explorer/package.json index c0de2b71b14..4175b470e5f 100644 --- a/mithril-explorer/package.json +++ b/mithril-explorer/package.json @@ -1,6 +1,6 @@ { "name": "mithril-explorer", - "version": "0.4.5", + "version": "0.4.6", "private": true, "scripts": { "dev": "next dev",