@revotale/react-hooks
v0.3.4
Published
Small React hooks with a stable, typed API.
Readme
@revotale/react-hooks
Small React hooks with a stable TypeScript API.
This package is a Bun/tsdown/TypeScript 6 restart of l-you/react-hooks and keeps the original root hook exports.
Install
bun add @revotale/react-hooksReact is a peer dependency.
Usage
import { useBool, useCallTrue, useToggle } from '@revotale/react-hooks'
function Example() {
const [open, setOpen] = useBool(false)
const show = useCallTrue(setOpen)
const toggle = useToggle(setOpen)
return (
<>
<button type="button" onClick={show}>
Show
</button>
<button type="button" onClick={toggle}>
{open ? 'Hide' : 'Show'}
</button>
</>
)
}Use root named imports. The package is marked as side-effect free, so modern bundlers can tree-shake unused hooks.
Exports
useBooluseCallFalseuseCallTrueuseDecrementuseFocusInputuseHTMLInputRefuseIncrementuseIntervaluseNumberuseOnChangeuseOnEnterDownuseOnMountuseOnceusePrevioususePromiseHandlerusePromiseStateuseRequireduseRequiredContextuseTimeoutuseTodayMidnightuseToggleuseVariableuseWasInViewuseWindowuseWindowHostuseWindowOriginuseWindowSize
Development
bun install
task validate
task test
task build
task check:packageRelease
Use Conventional Commits on main. release-please opens the release PR; merging it creates the GitHub release and publishes to npm from CI.
Configure npm Trusted Publishing for .github/workflows/release.yml after the first package publish. CI uses Bun for install, validation, tests, and build; npm is used only for the final registry publish.
