mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-16 01:41:02 +08:00
ea8ed28209
* chore: unified import method * fix lint
17 lines
397 B
TypeScript
17 lines
397 B
TypeScript
import 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;
|