Skip to content

Commit 28dbca3

Browse files
Merge pull request #594 from preactjs/iso-router-link-handler-race
2 parents 41bbf06 + 61b7318 commit 28dbca3

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

router.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export function LocationProvider(props) {
6363
return { url, path, query: Object.fromEntries(u.searchParams), route, wasPush };
6464
}, [url]);
6565

66-
useEffect(() => {
66+
useLayoutEffect(() => {
6767
addEventListener('click', route);
6868
addEventListener('popstate', route);
6969

test/router.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ describe('Router', () => {
429429
await sleep(20);
430430

431431
scratch.querySelector('a[href="/foo#foo"]').click();
432-
await sleep(100);
432+
await sleep(20);
433433
expect(Route).toHaveBeenCalledTimes(1);
434434
expect(loc).toMatchObject({ url: '/foo#foo', path: '/foo' });
435435
expect(pushState).toHaveBeenCalled();

0 commit comments

Comments
 (0)