Loading...
Loading...
Compare original and translation side by side
InvocationAUTOEXTERNALInvocationAUTOEXTERNALundefinedundefined
Alternatively, install the full npm package (all hooks bundled):
```bash
npm install shadcn-hooksWhen using the shadcn CLI, import from the local path (e.g.). When using the npm package, import fromimport { useBoolean } from "@/hooks/use-boolean"(e.g."shadcn-hooks").import { useBoolean } from "shadcn-hooks"
或者,安装完整的npm包(包含所有钩子):
```bash
npm install shadcn-hooks使用shadcn CLI时,从本地路径导入(例如)。 使用npm包时,从import { useBoolean } from "@/hooks/use-boolean"导入(例如"shadcn-hooks")。import { useBoolean } from "shadcn-hooks"
DescriptionReference./referencesDescriptionReference./references| Function | Description | Invocation |
|---|---|---|
| Boolean state with | AUTO |
| Supports both controlled and uncontrolled component patterns | AUTO |
| Counter with | AUTO |
| Debounced reactive value | AUTO |
| State with a | AUTO |
| Throttled reactive value | AUTO |
| Toggle between two values with utility actions | AUTO |
| 函数 | 描述 | 调用规则 |
|---|---|---|
| 带有 | AUTO |
| 支持受控与非受控组件两种模式 | AUTO |
| 带有 | AUTO |
| 防抖处理的响应式值 | AUTO |
| 带有 | AUTO |
| 节流处理的响应式值 | AUTO |
| 可在两个值间切换并附带工具方法的状态管理 | AUTO |
| Function | Description | Invocation |
|---|---|---|
| Memoized factory with deep dependency comparison | AUTO |
| | AUTO |
| Ref that always holds the latest value | AUTO |
| Prevents concurrent execution of an async function | AUTO |
| Stable function reference that never changes identity | AUTO |
| Returns the previous value of a state | AUTO |
| 函数 | 描述 | 调用规则 |
|---|---|---|
| 支持深度依赖比较的记忆化工厂函数 | AUTO |
| 带有自定义依赖比较器的 | AUTO |
| 始终持有最新值的Ref对象 | AUTO |
| 防止异步函数并发执行的锁机制 | AUTO |
| 引用稳定、标识永不改变的记忆化函数 | AUTO |
| 返回状态的上一个值 | AUTO |
| Function | Description | Invocation |
|---|---|---|
| Debounced | AUTO |
| Debounced function with | AUTO |
| | AUTO |
| | AUTO |
| Ponyfill for React 19's | AUTO |
| | AUTO |
| Interval timer with auto-cleanup | AUTO |
| Returns | AUTO |
| | AUTO |
| Runs a callback only on component mount | AUTO |
| Throttled | AUTO |
| Throttled function with | AUTO |
| Timeout timer with auto-cleanup | AUTO |
| Runs cleanup on component unmount | AUTO |
| Returns a function that forces component re-render | AUTO |
| | AUTO |
| 函数 | 描述 | 调用规则 |
|---|---|---|
| 防抖处理的 | AUTO |
| 带有 | AUTO |
| 带有深度依赖比较的 | AUTO |
| 带有深度依赖比较的 | AUTO |
| React 19中 | AUTO |
| 支持将目标DOM元素作为依赖的 | AUTO |
| 带有自动清理功能的间隔计时器 | AUTO |
| 在客户端 hydration 完成后返回 | AUTO |
| 客户端使用 | AUTO |
| 仅在组件挂载时执行回调函数 | AUTO |
| 节流处理的 | AUTO |
| 带有 | AUTO |
| 带有自动清理功能的超时计时器 | AUTO |
| 在组件卸载时执行清理操作 | AUTO |
| 返回一个强制组件重新渲染的函数 | AUTO |
| 跳过首次渲染的 | AUTO |
| Function | Description | Invocation |
|---|---|---|
| Track the currently focused element | AUTO |
| Reactive battery level and charging information | AUTO |
| Listen to click events anywhere on the document | AUTO |
| Detect clicks outside of target element(s) | AUTO |
| Reactive Clipboard API with read/write support | AUTO |
| Reactive document visibility state | AUTO |
| Reactive element size via ResizeObserver | AUTO |
| Declarative event listener with auto-cleanup | AUTO |
| Reactive FPS (frames per second) measurement | AUTO |
| Reactive Fullscreen API | AUTO |
| Reactive | AUTO |
| Reactive hover state of an element | AUTO |
| Track element visibility via IntersectionObserver | AUTO |
| Reactive CSS media query matching | AUTO |
| Reactive online/offline network status | AUTO |
| Reactive network connection information | AUTO |
| Lock/unlock scroll on a target element | AUTO |
| Reactive text selection state with bounding rect | AUTO |
| 函数 | 描述 | 调用规则 |
|---|---|---|
| 跟踪当前获得焦点的元素 | AUTO |
| 响应式的电池电量与充电状态信息 | AUTO |
| 监听文档内任意位置的点击事件 | AUTO |
| 检测目标元素外部的点击事件 | AUTO |
| 支持读写的响应式剪贴板API | AUTO |
| 响应式的文档可见性状态 | AUTO |
| 通过ResizeObserver实现的响应式元素尺寸 | AUTO |
| 声明式事件监听器,带有自动清理功能 | AUTO |
| 响应式的FPS(每秒帧数)测量 | AUTO |
| 响应式的全屏API | AUTO |
| 响应式的 | AUTO |
| 元素的响应式悬停状态 | AUTO |
| 通过IntersectionObserver跟踪元素可见性 | AUTO |
| 响应式的CSS媒体查询匹配状态 | AUTO |
| 响应式的网络在线/离线状态 | AUTO |
| 响应式的网络连接信息 | AUTO |
| 锁定/解锁目标元素的滚动功能 | AUTO |
| 带有边界矩形的响应式文本选择状态 | AUTO |
| Function | Description | Invocation |
|---|---|---|
| Logs which props changed between renders (debug only) | AUTO |
| 函数 | 描述 | 调用规则 |
|---|---|---|
| 记录渲染之间哪些props发生了变化(仅用于调试) | AUTO |
| Function | Description | Invocation |
|---|---|---|
| Model Context Protocol client hook from | EXTERNAL |
| Data fetching hook from | EXTERNAL |
| Scroll-stick behavior from | EXTERNAL |
| Data fetching hook from | EXTERNAL |
| 函数 | 描述 | 调用规则 |
|---|---|---|
| 来自 | EXTERNAL |
| 来自 | EXTERNAL |
| 来自 | EXTERNAL |
| 来自 | EXTERNAL |