Archiving this repository because - reactwg/react-18#82
Also this hook is availble in the new project, along with a bunch of other useful custom hooks. Please checkout https://github.com/aldrinpvincent/react-use-custom-hooks
Documentation of this hook in new project - https://react-use-custom-hooks.vercel.app/docs/useSafeState
Hook to prevent setting state on unmounted component that prevents memory leaks that happens when setting state on unmounted components.
npm i react-use-safe-state
import useSafeState from "react-use-safe-state";
const [state, setState] = useSafeState(initalValue);