UNPKG

@dailyshot/hooks

Version:

A set of hooks used in Dailyshot packages

23 lines (20 loc) 580 B
import { useState } from 'react'; function useUncontrolled({ value, defaultValue, finalValue, onChange = () => { } }) { const [uncontrolledValue, setUncontrolledValue] = useState(defaultValue !== void 0 ? defaultValue : finalValue); const handleUncontrolledChange = (val) => { setUncontrolledValue(val); onChange == null ? void 0 : onChange(val); }; if (value !== void 0) { return [value, onChange, true]; } return [uncontrolledValue, handleUncontrolledChange, false]; } export { useUncontrolled }; //# sourceMappingURL=use-uncontrolled.js.map