-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
style(dialog): animate dialog height change through prop (#1363)
- Loading branch information
Showing
4 changed files
with
208 additions
and
129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { useCallback, useEffect, useRef } from 'react'; | ||
|
||
/** | ||
* @description Custom hook that determines if the component is currently mounted. | ||
* @url https://usehooks-ts.com/react-hook/use-is-mounted | ||
*/ | ||
export function useIsMounted(): () => boolean { | ||
const isMounted = useRef(false); | ||
|
||
useEffect(() => { | ||
isMounted.current = true; | ||
|
||
return () => { | ||
isMounted.current = false; | ||
}; | ||
}, []); | ||
|
||
return useCallback(() => isMounted.current, []); | ||
} |
Oops, something went wrong.