ant-design/components/typography/hooks/useUpdatedEffect.ts
2023-05-06 15:49:37 +08:00

17 lines
402 B
TypeScript

import * as React from 'react';
/** Similar with `useEffect` but only trigger after mounted */
const useUpdatedEffect = (callback: () => void, conditions?: React.DependencyList) => {
const mountRef = React.useRef(false);
React.useEffect(() => {
if (mountRef.current) {
callback();
} else {
mountRef.current = true;
}
}, conditions);
};
export default useUpdatedEffect;