@thisisagile/easy-react
Version:
Straightforward library building micro applications in react
10 lines (8 loc) • 448 B
text/typescript
import { Dispatch, SetStateAction, useState as useReactState } from 'react';
export function useState<T>(): [T | undefined, Dispatch<SetStateAction<T | undefined>>, () => void];
export function useState<T>(initial: T): [T, Dispatch<SetStateAction<T>>, () => void];
export function useState<T>(initial?: T) {
const [state, setState] = useReactState(initial);
const reset = () => setState(initial);
return [state, setState, reset] as const;
}