Skip to content

Commit 9c9f80e

Browse files
committed
requestAnimationFrame
1 parent a66d04f commit 9c9f80e

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

v2/navigation.jsx

+5-3
Original file line numberDiff line numberDiff line change
@@ -317,16 +317,18 @@ export function Navigation(props) {
317317

318318
dispatch({ type: 'replace', stack: newStack, opts: { animate: false } });
319319

320-
// Pop to root screen
321-
setTimeout(() => {
320+
// TODO: build a more integrated solution for sequencing dispatches
321+
// For now, we'll use requestAnimationFrame
322+
requestAnimationFrame(() => {
323+
// Pop to root screen
322324
dispatch({ type: 'pop', opts: { animate: props.animate } });
323325

324326
// Update URL
325327
const url = new URL(window.location.href);
326328
url.searchParams.delete('stack');
327329
url.searchParams.append('stack', primaryScreen);
328330
window.history.replaceState({}, '', url);
329-
}, 0);
331+
});
330332
},
331333
canPop: canPop,
332334
canPopFrom: canPopFrom,

0 commit comments

Comments
 (0)