Skip to content

Commit

Permalink
fix(code): hoistOnInit
Browse files Browse the repository at this point in the history
Return an unsubscribe function to prevent leaks
  • Loading branch information
adam-26 committed Mar 1, 2018
1 parent fd26dd4 commit c5b6c28
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/index.js
Expand Up @@ -218,15 +218,23 @@ function createChunkComponent(loadFn, options) {

if (!opts.hoistStatics) {
// nothing to hoist
return;
return noop;
}

if (res && res.loaded) {
hoistNonActionStatics(getTargetComponent(), opts.resolveDefaultImport(res.loaded));
return;
return noop;
}

dynamicHoistComponentGetters.push(getTargetComponent);

// Return an unsubscribe function
return () => {
const idx = dynamicHoistComponentGetters.indexOf(getTargetComponent);
if (idx !== -1) {
dynamicHoistComponentGetters.splice(idx, 1);
}
};
}

_loadChunks() {
Expand Down

0 comments on commit c5b6c28

Please sign in to comment.