Server: Phase 2 (REVIEW not respected yet)
This commit is contained in:
1 parent
5d16ded553
commit
142b47674d
4271 files changed
+1203269
No files matched your search
+30
@@ -0,0 +1,30 @@
|
||||
import { useMatch } from "./useMatch.js";
|
||||
//#region src/useParams.tsx
|
||||
/**
|
||||
* Access the current route's path parameters with type-safety.
|
||||
*
|
||||
* Options:
|
||||
* - `from`/`strict`: Specify the matched route and whether to enforce strict typing
|
||||
* - `select`: Project the params object to a derived value for memoized renders
|
||||
* - `structuralSharing`: Enable structural sharing for stable references
|
||||
* - `shouldThrow`: Throw if the route is not found in strict contexts
|
||||
*
|
||||
* @returns The params object (or selected value) for the matched route.
|
||||
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/useParamsHook
|
||||
*/
|
||||
function useParams(opts) {
|
||||
return useMatch({
|
||||
from: opts.from,
|
||||
shouldThrow: opts.shouldThrow,
|
||||
structuralSharing: opts.structuralSharing,
|
||||
strict: opts.strict,
|
||||
select: (match) => {
|
||||
const params = opts.strict === false ? match.params : match._strictParams;
|
||||
return opts.select ? opts.select(params) : params;
|
||||
}
|
||||
});
|
||||
}
|
||||
//#endregion
|
||||
export { useParams };
|
||||
|
||||
//# sourceMappingURL=useParams.js.map
|
||||
Reference in new issue
Block a user