mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-05 09:49:57 +08:00
15 lines
342 B
TypeScript
15 lines
342 B
TypeScript
|
import * as React from 'react';
|
||
|
|
||
|
/** Similar with `useEffect` but only trigger after mounted */
|
||
|
export default (callback: () => void, conditions: any[]) => {
|
||
|
const mountRef = React.useRef(false);
|
||
|
|
||
|
React.useEffect(() => {
|
||
|
if (mountRef.current) {
|
||
|
callback();
|
||
|
} else {
|
||
|
mountRef.current = true;
|
||
|
}
|
||
|
}, conditions);
|
||
|
};
|