-
Notifications
You must be signed in to change notification settings - Fork 232
Closed
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomersquestionFurther information is requestedFurther information is requested
Description
I have an effect that uses setInterval
. In order for my tests to work right, I need to unmount
so the interval gets knocked away.
I have code like this:
let globalUnmount;
// I use this is all of my tests to run render the hook
async function runEffects(wait = true) {
const { result, unmount } = renderHook(() =>
useMyHookWithIntervals()
);
globalUnmount = unmount;
return {
result
};
}
afterEach(() => {
if (globalUnmount) {
globalUnmount();
globalUnmount = null;
}
});
Is this the expected paradigm? Is this an example that would be good for docs? Is this horrible?
jameslnewell, kripod and dyatkoReston and jljorgenson18
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomersquestionFurther information is requestedFurther information is requested