Skip to content
This repository has been archived by the owner on Mar 13, 2022. It is now read-only.

Latest commit

 

History

History
34 lines (17 loc) · 876 Bytes

README.md

File metadata and controls

34 lines (17 loc) · 876 Bytes

Archiving this repository

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

useSafeState

Hook to prevent setting state on unmounted component that prevents memory leaks that happens when setting state on unmounted components.

Installation

  npm i react-use-safe-state

Usage

Importing component

import useSafeState from "react-use-safe-state";

const [state, setState] = useSafeState(initalValue);

react-use-safe-state downloads per month