Skip to content

Loaders deps less verbose #2505

Discussion options

You must be logged in to vote

we have a function pick in router, although it's exported it's not part of the public API.

you could use it like this:

export function pick<TValue, TKey extends keyof TValue>(
  parent: TValue,
  keys: Array<TKey>,
): Pick<TValue, TKey> {
  return keys.reduce((obj: any, key: TKey) => {
    obj[key] = parent[key]
    return obj
  }, {} as any)
}

export const Route = createFileRoute('/_app/claims/')({
  validateSearch: zodSearchValidator(ClaimsRequest),
  loaderDeps: ({ search }) => pick(search, [
      'pageNumber',
      'pageSize',
      'search',
      'column',
      'desc',
      'eventTypes',
      'registers',
      'destuctionDegrees'
    ]),
  loader: ({ deps }) => queryClient.en…

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@andredewaard
Comment options

@andredewaard
Comment options

@schiller-manuel
Comment options

@andredewaard
Comment options

Answer selected by andredewaard
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants