GuobaGuoba Utils

@guoba-ai/hook

@guoba-ai/hook

npm License: MIT

A small collection of React hooks — ESM-only, fully typed.

Installation

pnpm add @guoba-ai/hook

Requires React 18+ as a peer dependency.

Usage

import { useDebounce, useToggle } from '@guoba-ai/hook'
import { useState } from 'react'

function Example() {
  const [on, toggle] = useToggle(false)
  const [q, setQ] = useState('')
  const debouncedQ = useDebounce(q, 300)
  // ...
}

Available Hooks

  • useDebounce — debounce a value
  • useThrottle — throttle a value
  • useToggle — boolean state with toggle
  • usePrevious — read the previous render's value
  • useMount — run callback on mount
  • useUnmount — run callback on unmount
  • useSyncState — state with ref-sync access

📖 Full API referenceguoba-ai.vercel.app/docs/hooks

License

MIT

On this page