react-easier
Version:
Useful React hooks that minimize the complexity of state handling, contexts and fetching.
19 lines (17 loc) • 344 B
JavaScript
import { useEffect } from 'react';
export function useOnMount(func) {
const funcWrapped = function () {
(async () => {
func();
})();
}
useEffect(funcWrapped, []);
}
export function useOnCleanup(func) {
const funcWrapped = function () {
(async () => {
func();
})();
}
useEffect(() => funcWrapped, []);
}