mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-24 02:24:59 +08:00
first commit
This commit is contained in:
12
webapp/packages/supersonic-fe/src/hooks/useMounted.ts
Normal file
12
webapp/packages/supersonic-fe/src/hooks/useMounted.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import { useEffect, useRef } from 'react';
|
||||
|
||||
export const useMounted = () => {
|
||||
const mountedRef = useRef(false);
|
||||
useEffect(() => {
|
||||
mountedRef.current = true;
|
||||
return () => {
|
||||
mountedRef.current = false;
|
||||
};
|
||||
}, []);
|
||||
return () => mountedRef.current;
|
||||
};
|
||||
Reference in New Issue
Block a user