@saplings/hooks
v0.17.2
Published
Use typed React hooks for controlled state, asynchronous work, browser events, and storage.
Downloads
485
Readme
@saplings/hooks
Use typed React hooks for controlled state, asynchronous work, browser events, and storage.
Install
npm install @saplings/hooks reactQuick start
import { useCounter } from '@saplings/hooks';
export function Counter() {
const { value, increment, reset } = useCounter(0);
return (
<>
<output>{value}</output>
<button onClick={() => increment()}>Increment</button>
<button onClick={() => reset()}>Reset</button>
</>
);
}API and integration
useCounter(initial?)gives you the current value and state actions.useDebounce(value, delayMs?)returns the debounced value.- Use hooks inside React components or custom hooks. Check each browser and storage hook's SSR behavior before using it in a server-rendered application.
- Provide the React peer from your host application.
Read the integration guide for configuration and operational details.
