Skip to content
This repository has been archived by the owner on Nov 23, 2024. It is now read-only.

Commit

Permalink
Cleanup useMutation ref
Browse files Browse the repository at this point in the history
  • Loading branch information
msutkowski committed Mar 16, 2021
1 parent d20b646 commit 08ef189
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/react-hooks/buildHooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,13 @@ export function buildHooks<Definitions extends EndpointDefinitions>({

const promiseRef = useRef<MutationActionCreatorResult<any>>();

useEffect(() => () => void promiseRef.current?.unsubscribe(), []);
useEffect(() => {
return () => {
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
promiseRef.current?.unsubscribe();
promiseRef.current = undefined;
};
}, []);

const triggerMutation = useCallback(
function (args) {
Expand Down

0 comments on commit 08ef189

Please sign in to comment.