fix(react-router): route-context being available and loaders being called after a redirection #1713
MergedSeanCassieremerged 48 commits into
main fromrefs/pull/1713/headmerged by SeanCassiere SeanCassiere reviewed
packages/react-router/src/Transitioner.tsx line 32@@ -29,4 +29,4 @@29293030 // Subscribe to location changes3131 // and try to load the new location32- useLayoutEffect(() => {32+ React.useEffect(() => {SeanCassiere reviewed
packages/react-router/src/router.ts line 1786@@ -1763,18 +1763,7 @@17631763 parentContext,17641764 ),1765+ context: replaceEqualDeep(match.context, parentContext),17651766 abortController,1766- }))1767+ }176717681768- const beforeLoadContext =1769- (await route.options.beforeLoad?.({1770- search: match.search,1771- abortController,1772- params: match.params,1773- preload: !!preload,1774- context: parentContext,1775- location,1776- navigate: (opts: any) =>1777- this.navigate({ ...opts, from: match.pathname }),1778- buildLocation: this.buildLocation,1779- cause: preload ? 'preload' : match.cause,1780- })) ?? ({} as any)1769+ const beforeLoadFnContext = {SeanCassiere reviewed
Resolvedby SeanCassiere@@ -1833,4 +1837,4 @@18331837 route,18341838 }183518391836- const fetch = async () => {1840+ const fetchAndResolveInLoaderLifetime = async () => {SeanCassiere reviewed
OutdatedResolvedby SeanCassiere@@ -1903,4 +1907,4 @@19031907 // we can use the options19041908 await lazyPromise190519091906- checkLatest()1910+ // checkLatest()SeanCassiere reviewed
OutdatedResolvedby SeanCassiere@@ -516,3 +516,4 @@516516 }517517 const router = createContextRouter(['/'], 'BEFORE_LOAD', ctx)518518 await router.load()519+ await router.invalidate()SeanCassiere reviewed
packages/react-router/src/router.ts line 1551@@ -1548,4 +1548,4 @@15481548 redirect = err15491549 if (!this.isServer) {15501550 this.navigate({ ...err, replace: true, __isRedirect: true })1551- this.load()1551+ // this.load()SeanCassiere changed the title
SeanCassiere reviewed
packages/react-router/tests/redirects.test.tsx line 467@@ -463,5 +459,3 @@463459 expect(router.state.location.pathname).toBe('/g/tkdodo')464460 })465461 })466-467-function createContextRouter<TCtx extends Record<string, unknown>>(SeanCassiere merged this950561a
SeanCassiere closed this
Sign in to join this conversation.
☁️ Nx Cloud Report#
CI is running/has finished running commands for commit d65e453d2f287986b14a8fd9a7ea5bb6584d022c. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.
📂 See all runs for this CI Pipeline Execution
✅ Successfully ran 4 targets
nx affected --targets=test:format,test:eslint,test:unit,test:build,build --parallel=3nx run-many --target=test:e2e:replaynx affected --target=build --exclude=examples/**nx affected --target=test:types --exclude=examples/**Sent with 💌 from NxCloud.