ant-design/components/typography/hooks/useUpdatedEffect.ts

17 lines
402 B
TypeScript
Raw Normal View History

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