Skip to content

Commit

Permalink
fix: Pass through the unused title parameter
Browse files Browse the repository at this point in the history
Even though it seems to be unused in mostly browsers,
passing it through ensures we don't break user code.
  • Loading branch information
franky47 committed Sep 11, 2023
1 parent 5b7c494 commit 731bde4
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/lib/sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ export function usePatchedHistory() {
const original = window.history[method].bind(window.history)
window.history[method] = function nextUseQueryState_patchedHistory(
state: any,
marker: string,
title: string,
url?: string | URL | null
) {
// If someone else than our hooks have updated the URL,
// send out a signal for them to sync their internal state.
if (marker !== NOSYNC_MARKER && url) {
if (title !== NOSYNC_MARKER && url) {
const search = new URL(url, location.origin).searchParams
// Here we're delaying application to next tick to avoid:
// `Warning: useInsertionEffect must not schedule updates.`
Expand All @@ -50,7 +50,7 @@ export function usePatchedHistory() {
// to rely on the URL being up to date.
setTimeout(() => emitter.emit(SYNC_EVENT_KEY, search), 0)
}
return original(state, '', url)
return original(state, title === NOSYNC_MARKER ? '' : title, url)
}
}
patched = true
Expand Down

0 comments on commit 731bde4

Please sign in to comment.