Router loader search
parameter gone?
#1297
-
According to these docs: The However, after updating to the latest version ( export type RouteLoaderFn<
TAllParams = {},
TLoaderDeps extends Record<string, any> = {},
TAllContext extends Record<string, any> = AnyContext,
TRouteContext extends Record<string, any> = AnyContext,
TLoaderData extends any = unknown,
> = (
match: LoaderFnContext<TAllParams, TLoaderDeps, TAllContext, TRouteContext>,
) => Promise<TLoaderData> | TLoaderData | void
export interface LoaderFnContext<
TAllParams = {},
TLoaderDeps extends Record<string, any> = {},
TAllContext extends Record<string, any> = AnyContext,
TRouteContext extends Record<string, any> = AnyContext,
> {
abortController: AbortController
preload: boolean
params: TAllParams
deps: TLoaderDeps
context: Expand<Assign<TAllContext, TRouteContext>>
location: ParsedLocation // Do not supply search schema here so as to demotivate people from trying to shortcut loaderDeps
navigate: (opts: NavigateOptions<AnyRoute>) => Promise<void>
parentMatchPromise?: Promise<void>
cause: 'preload' | 'enter' | 'stay'
route: Route
} The parameter was available on previous version ( |
Beta Was this translation helpful? Give feedback.
Answered by
BrendanC23
Mar 12, 2024
Replies: 1 comment
-
You can use the // /routes/posts.tsx
export const Route = createFileRoute('/posts')({
loaderDeps: ({ search: { offset, limit } }) => ({ offset, limit }),
loader: ({ deps: { offset, limit } }) =>
fetchPosts({
offset,
limit,
}),
}) See this section for an explanation about why |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
Jarzka
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can use the
loaderDeps
field to access search params. See these docs.See this section for an explanation about why
loaderDeps
is necessary.