useMountedRef
It returns a ref object that used to determine whether the component is mounted.
API
function useMountedRef(): React.MutableRefObject<boolean>;
Example
import React from "react";
import { useMountedRef } from "@lilib/hooks";
function Example() {
const mountedRef = useMountedRef();
if (mountedRef.current) {
// Do something.
}
...
}