useUnmountedRef

A React Hook that helps to create a ref that can be checked if the component is unmounted. It is recommended to use useUnmounted (Ref Getter) to get the unmount status

Demo

Try to click Start Timer, and then click the "Toggle mount" button in one second to see the result.

Source

Usage

See API for more details.

Source

Click links below to view source on GitHub.

API

const unmountedRef = useUnmountedRef()

Returns

A React Ref that can be checked if the component is unmounted.