Skip to content

Commit

Permalink
Merge pull request #3 from JReinhold/patch-1
Browse files Browse the repository at this point in the history
FIX: Only invoke destroy if it exists @JReinhold
  • Loading branch information
rauldeheer authored Mar 13, 2019
2 parents 3e3dc66 + 15fc2a1 commit 701872f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ module.exports.useAsyncEffect = (effect, destroy, inputs) => {
useEffect(() => {
let result;
effect().then((value) => result = value);

return () => destroy(result);

if(typeof destroy === 'function'){
return () => destroy(result);
}
}, inputs);
};

0 comments on commit 701872f

Please sign in to comment.