useMounted

A React Hook that returns a Ref Getter that indicates whether the component is mounted or not.

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 isMounted = useMounted()

isMounted is a Ref Getter that returns a boolean value.

See Ref Getter for more details.

Returns

A Ref Getter that return a boolean value that indicates whether the component is mounted or not.