Skip to content

Commit

Permalink
fix: autoload updates on passed HMR event, fixes #160
Browse files Browse the repository at this point in the history
  • Loading branch information
theKashey committed Nov 19, 2019
1 parent 5d0b47e commit 6a487a8
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/useImported.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,13 @@ export function useImported<T, K = T>(
useEffect(() => {
if (postEffectRef.current) {
executeLoadableEventually(loadable, () => settings.updateOnReload && update({}));
} else {
// initial render
// if it's already loading - do nothing
// however - if it's already loaded (cannot be so quick) - that's an indication of passed HMR event
if (!loadable.isLoading()) {
executeLoadableEventually(loadable, () => settings.updateOnReload && update({}));
}
}

postEffectRef.current = true;
Expand Down

0 comments on commit 6a487a8

Please sign in to comment.