ant-design/components/_util/hooks/useDestroyed.ts

15 lines
255 B
TypeScript

import * as React from 'react';
export default function useDestroyed() {
const mountedRef = React.useRef<boolean>(true);
React.useEffect(
() => () => {
mountedRef.current = false;
},
[],
);
return () => !mountedRef.current;
}