Skip to content

use-hash-location subscribes to hashchange once#381

Merged
molefrog merged 1 commit intov3from
fix/hash-location-async-event
Nov 9, 2023
Merged

use-hash-location subscribes to hashchange once#381
molefrog merged 1 commit intov3from
fix/hash-location-async-event

Conversation

@molefrog
Copy link
Owner

@molefrog molefrog commented Nov 8, 2023

To fix tearing issue when hashchange is fired asynchronously.
See this discussion whatwg/html#1792

TLDR; React schedules micro-task in between calls to hashchange event listeners, because in some browsers this event is fired asynchronously (e.g. WebKit does it). This results in teared state when some components receive updates faster than others and it happens within one micro-task.

To fix tearing issue when `hashchange` is fired asynchronously.
@molefrog molefrog requested a review from jeetiss November 8, 2023 13:29
@codesandbox
Copy link

codesandbox bot commented Nov 8, 2023

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

@bolt-new-by-stackblitz
Copy link

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@molefrog molefrog changed the title use-hash-location subscribes to hashchange only once use-hash-location subscribes to hashchange once Nov 8, 2023
@github-actions
Copy link

github-actions bot commented Nov 8, 2023

size-limit report 📦

Path Size
packages/wouter/esm/index.js 2.05 KB (0%)
packages/wouter/esm/use-browser-location.js 658 B (0%)
packages/wouter/esm/memory-location.js 836 B (0%)
packages/wouter/esm/use-hash-location.js 734 B (+8.75% 🔺)
packages/wouter-preact/esm/index.js 1.94 KB (0%)
packages/wouter-preact/esm/use-browser-location.js 553 B (0%)
packages/wouter-preact/esm/use-hash-location.js 609 B (+10.13% 🔺)
packages/wouter-preact/esm/memory-location.js 703 B (0%)

@molefrog molefrog merged commit 1081a5d into v3 Nov 9, 2023
@molefrog molefrog deleted the fix/hash-location-async-event branch November 9, 2023 11:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants