Skip to content

Commit 701872f

Browse files
author
rauldeheer
authored
Merge pull request #3 from JReinhold/patch-1
FIX: Only invoke destroy if it exists @JReinhold
2 parents 3e3dc66 + 15fc2a1 commit 701872f

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ module.exports.useAsyncEffect = (effect, destroy, inputs) => {
44
useEffect(() => {
55
let result;
66
effect().then((value) => result = value);
7-
8-
return () => destroy(result);
7+
8+
if(typeof destroy === 'function'){
9+
return () => destroy(result);
10+
}
911
}, inputs);
1012
};

0 commit comments

Comments
 (0)