Skip to content

Commit

Permalink
Use replaceState when updating URL hash
Browse files Browse the repository at this point in the history
This prevents a new entry from being pushed onto the browser's history stack.
  • Loading branch information
jake-low committed Sep 4, 2024
1 parent 883be35 commit c78e0e1
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/hooks/UseHash.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const useHash = () => {
const updateHash = useCallback(
(newHash) => {

Check warning on line 23 in src/hooks/UseHash.js

View check run for this annotation

Codecov / codecov/patch

src/hooks/UseHash.js#L22-L23

Added lines #L22 - L23 were not covered by tests
if (newHash !== hash) {
window.location.hash = newHash;
history.replaceState(null, null, newHash);

Check warning on line 25 in src/hooks/UseHash.js

View check run for this annotation

Codecov / codecov/patch

src/hooks/UseHash.js#L25

Added line #L25 was not covered by tests
}
},
[hash],
Expand Down

0 comments on commit c78e0e1

Please sign in to comment.