refactor more hooks

This commit is contained in:
2022-07-25 13:11:40 -04:00
parent 37feb305ff
commit cf106e46da
18 changed files with 246 additions and 296 deletions
+15
View File
@@ -0,0 +1,15 @@
import { useEffect } from "react";
import useFirstMountState from "./useFirstMountState";
// identical to `useEffect()` but ignores the first invocation
const useUpdateEffect: typeof useEffect = (effect, deps) => {
const isFirstMount = useFirstMountState();
useEffect(() => {
if (!isFirstMount) {
return effect();
}
}, deps); // eslint-disable-line react-hooks/exhaustive-deps
};
export default useUpdateEffect;