UNPKG

react-reuse-hooks

Version:

A collection of 30+ production-ready reusable React hooks for web apps, covering state, effects, media, forms, and utilities.

14 lines (10 loc) 279 B
import { useState } from "react"; export function useInput(initialValue) { const [value, setValue] = useState(initialValue); const onChange = (e) => setValue(e.target.value); return { value, onChange, reset: () => setValue(initialValue), }; }