From 3cef94b4afe86610dae54ace24a9057ca97a7618 Mon Sep 17 00:00:00 2001 From: Ramon Date: Thu, 8 Jun 2023 16:09:44 +1000 Subject: [PATCH] Global styles revisions: ensure redirect runs once for back button (#51316) * Removing location?.path from the dependency to avoid infinite loop and to ensure the internal functions are run once, and as intendted * Add disable lint rule --- packages/edit-site/src/components/global-styles/ui.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/edit-site/src/components/global-styles/ui.js b/packages/edit-site/src/components/global-styles/ui.js index 953904e314928..7d068042ef533 100644 --- a/packages/edit-site/src/components/global-styles/ui.js +++ b/packages/edit-site/src/components/global-styles/ui.js @@ -261,7 +261,11 @@ function GlobalStylesEditorCanvasContainerLink() { // redirect from the revisions screen to the root global styles screen. goTo( '/' ); } - }, [ editorCanvasContainerView, location?.path, goTo ] ); + // location?.path is not a dependency because we don't want to track it. + // Doing so will cause an infinite loop. We could abstract logic to avoid + // having to disable the check later. + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [ editorCanvasContainerView, goTo ] ); } function GlobalStylesUI() {