mirror of
https://github.com/tencentmusic/supersonic.git
synced 2026-01-01 23:08:25 +08:00
13 lines
273 B
TypeScript
13 lines
273 B
TypeScript
import { useEffect, useRef } from 'react';
|
|
|
|
export const useMounted = () => {
|
|
const mountedRef = useRef(false);
|
|
useEffect(() => {
|
|
mountedRef.current = true;
|
|
return () => {
|
|
mountedRef.current = false;
|
|
};
|
|
}, []);
|
|
return () => mountedRef.current;
|
|
};
|