You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
15 lines
342 B
15 lines
342 B
3 years ago
|
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);
|
||
|
};
|