Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use-hash-location subscribes to hashchange once #381

Merged
merged 1 commit into from Nov 9, 2023

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
Copy link

codesandbox bot commented Nov 8, 2023

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

Copy link

stackblitz bot commented Nov 8, 2023

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
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
2 checks passed
@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.

None yet

2 participants