mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-22 22:48:29 +08:00
ac5a06027e
This reverts commit ea8ed28209
.
17 lines
402 B
TypeScript
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;
|