Skip to content

Commit

Permalink
Global styles revisions: ensure redirect runs once for back button (W…
Browse files Browse the repository at this point in the history
…ordPress#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
  • Loading branch information
ramonjd authored and sethrubenstein committed Jul 13, 2023
1 parent 8b5f01b commit 7c9cddc
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/edit-site/src/components/global-styles/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit 7c9cddc

Please sign in to comment.