MCPcopy
hub / github.com/TanStack/router / tryNavigation

Function tryNavigation

packages/history/src/index.ts:129–159  ·  view source on GitHub ↗
({
    task,
    navigateOpts,
    ...actionInfo
  }: TryNavigateArgs)

Source from the content-addressed store, hash-verified

127 }
128
129 const tryNavigation = async ({
130 task,
131 navigateOpts,
132 ...actionInfo
133 }: TryNavigateArgs) => {
134 const ignoreBlocker = navigateOpts?.ignoreBlocker ?? false
135 if (ignoreBlocker) {
136 task()
137 return
138 }
139
140 const blockers = opts.getBlockers?.() ?? []
141 const isPushOrReplace =
142 actionInfo.type === 'PUSH' || actionInfo.type === 'REPLACE'
143 if (typeof document !== 'undefined' && blockers.length && isPushOrReplace) {
144 for (const blocker of blockers) {
145 const nextLocation = parseHref(actionInfo.path, actionInfo.state)
146 const isBlocked = await blocker.blockerFn({
147 currentLocation: location,
148 nextLocation,
149 action: actionInfo.type,
150 })
151 if (isBlocked) {
152 opts.onBlocked?.()
153 return
154 }
155 }
156 }
157
158 task()
159 }
160
161 return {
162 get location() {

Callers 1

createHistoryFunction · 0.85

Calls 1

parseHrefFunction · 0.85

Tested by

no test coverage detected