mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-12 07:09:55 +08:00
15 lines
255 B
TypeScript
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;
|
|
}
|