From aeb4871a98a32c976139dee4b54b0923cf7b0eda Mon Sep 17 00:00:00 2001 From: "coderabbitai[bot]" <136622811+coderabbitai[bot]@users.noreply.github.com> Date: Fri, 3 Oct 2025 08:14:14 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=9D=20Add=20docstrings=20to=20`fix/sol?= =?UTF-8?q?id-router-use-loader-deps-accessor`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Docstrings generation was requested by @edmolima. * https://github.com/TanStack/router/pull/5348#issuecomment-3364719091 The following files were modified: * `packages/solid-router/src/useLoaderDeps.tsx` --- packages/solid-router/src/useLoaderDeps.tsx | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/packages/solid-router/src/useLoaderDeps.tsx b/packages/solid-router/src/useLoaderDeps.tsx index 91e5acb308c..4563ff09d5a 100644 --- a/packages/solid-router/src/useLoaderDeps.tsx +++ b/packages/solid-router/src/useLoaderDeps.tsx @@ -1,4 +1,3 @@ -import { useMatch } from './useMatch' import type { AnyRouter, RegisteredRouter, @@ -6,6 +5,8 @@ import type { StrictOrFrom, UseLoaderDepsResult, } from '@tanstack/router-core' +import type { Accessor } from 'solid-js' +import { useMatch } from './useMatch' export interface UseLoaderDepsBaseOptions< TRouter extends AnyRouter, @@ -27,20 +28,31 @@ export type UseLoaderDepsRoute = < TSelected = unknown, >( opts?: UseLoaderDepsBaseOptions, -) => UseLoaderDepsResult +) => Accessor> +/** + * Selects and returns the matched route's loader dependencies as a Solid `Accessor`. + * + * When a `select` function is provided in `opts`, the accessor yields the result of applying + * that function to the matched route's `loaderDeps`. Otherwise the accessor yields the + * route's raw `loaderDeps`. + * + * @param opts - Options that specify which route to match and an optional `select` mapper + * to transform the matched route's `loaderDeps`. + * @returns An `Accessor` that yields the selected loader dependencies for the matched route. + */ export function useLoaderDeps< TRouter extends AnyRouter = RegisteredRouter, const TFrom extends string | undefined = undefined, TSelected = unknown, >( opts: UseLoaderDepsOptions, -): UseLoaderDepsResult { +): Accessor> { const { select, ...rest } = opts return useMatch({ ...rest, select: (s) => { return select ? select(s.loaderDeps) : s.loaderDeps }, - }) as UseLoaderDepsResult + }) as Accessor> }