UNPKG

@eoet/use-state-if-mounted

Version:

A hook for updating state only if the component is mounted.

4 lines (2 loc) 152 B
import { Dispatch, SetStateAction } from 'react'; export function useStateIfMounted<S>(initialState: S | (() => S)): [S, Dispatch<SetStateAction<S>>];