Skip to content

Commit

Permalink
Fix promise checking
Browse files Browse the repository at this point in the history
  • Loading branch information
marcospassos committed Jun 10, 2021
1 parent 95a2957 commit b212bfd
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/hooks/useLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ export function useLoader<R>({initial, ...options}: CacheOptions<R>): R {
try {
setValue(cache.load(options));
} catch (result) {
if (!(result instanceof Promise)) {
if (result?.then !== 'function') {
setValue(undefined);

return;
}

result.then(resolvedValue => {
result.then((resolvedValue: R) => {
if (!isUnmounted) {
setValue(resolvedValue);
}
Expand Down

0 comments on commit b212bfd

Please sign in to comment.