File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ ---
2+ ' @tanstack/solid-router ' : patch
3+ ---
4+
5+ Remove unnecessary setTimeout from Match components
Original file line number Diff line number Diff line change @@ -340,7 +340,7 @@ export function createBrowserHistory(opts?: {
340340
341341 // We need to track the current scheduled update to prevent
342342 // multiple updates from being scheduled at the same time.
343- let scheduled : Promise < void > | undefined
343+ let scheduled : undefined | boolean
344344
345345 // This function flushes the next update to the browser history
346346 const flush = ( ) => {
@@ -363,7 +363,7 @@ export function createBrowserHistory(opts?: {
363363
364364 // Reset the nextIsPush flag and clear the scheduled update
365365 next = undefined
366- scheduled = undefined
366+ scheduled = false
367367 rollbackLocation = undefined
368368 }
369369
@@ -391,7 +391,8 @@ export function createBrowserHistory(opts?: {
391391
392392 if ( ! scheduled ) {
393393 // Schedule an update to the browser history
394- scheduled = Promise . resolve ( ) . then ( ( ) => flush ( ) )
394+ scheduled = true
395+ queueMicrotask ( ( ) => flush ( ) )
395396 }
396397 }
397398
Original file line number Diff line number Diff line change @@ -2294,7 +2294,7 @@ export class RouterCore<
22942294
22952295 // Clear pending location after commit starts
22962296 // We do this on next microtask to allow synchronous navigate calls to chain
2297- Promise . resolve ( ) . then ( ( ) => {
2297+ queueMicrotask ( ( ) => {
22982298 if ( this . pendingBuiltLocation === location ) {
22992299 this . pendingBuiltLocation = undefined
23002300 }
@@ -2354,7 +2354,7 @@ export class RouterCore<
23542354 `Blocked navigation to dangerous protocol: ${ reloadHref } ` ,
23552355 )
23562356 }
2357- return Promise . resolve ( )
2357+ return
23582358 }
23592359
23602360 // Check blockers for external URLs unless ignoreBlocker is true
@@ -2370,7 +2370,7 @@ export class RouterCore<
23702370 action : 'PUSH' ,
23712371 } )
23722372 if ( shouldBlock ) {
2373- return Promise . resolve ( )
2373+ return
23742374 }
23752375 }
23762376 }
@@ -2381,7 +2381,7 @@ export class RouterCore<
23812381 } else {
23822382 window . location . href = reloadHref
23832383 }
2384- return Promise . resolve ( )
2384+ return
23852385 }
23862386
23872387 return this . buildAndCommitLocation ( {
Original file line number Diff line number Diff line change @@ -354,7 +354,7 @@ export const MatchInner = (): any => {
354354 }
355355
356356 const [ loaderResult ] = Solid . createResource ( async ( ) => {
357- await new Promise ( ( r ) => setTimeout ( r , 0 ) )
357+ await Promise . resolve ( )
358358 return router . getMatch ( currentMatch ( ) . id ) ?. _nonReactive
359359 . loadPromise
360360 } )
@@ -411,7 +411,7 @@ export const MatchInner = (): any => {
411411 }
412412
413413 const [ loaderResult ] = Solid . createResource ( async ( ) => {
414- await new Promise ( ( r ) => setTimeout ( r , 0 ) )
414+ await Promise . resolve ( )
415415 return getLoadPromise ( matchId , routerMatch )
416416 } )
417417
You can’t perform that action at this time.
0 commit comments