@tapjs/reporter
Version:
Pretty test output reporters for tap
16 lines • 478 B
JavaScript
import { useLayoutEffect } from 'react';
// push cleanup functions onto the array, and they'll be cleaned up
export const useCleanup = (effect, deps) => useLayoutEffect(() => {
const cleanup = [];
let c = undefined;
const doCleanup = () => {
if (c)
c();
for (const c of cleanup)
c();
cleanup.length = 0;
};
c = effect(cleanup, doCleanup);
return doCleanup;
}, deps);
//# sourceMappingURL=use-cleanup.js.map