Skip to content

Commit

Permalink
fix: allow hot reloading for server cases
Browse files Browse the repository at this point in the history
  • Loading branch information
theKashey committed Mar 4, 2021
1 parent d67a211 commit 8144a9f
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/ui/HOC.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@ function loader<P, K = P>(
loaderFunction: DefaultComponentImport<P>,
baseOptions: Partial<ComponentOptions<P, K>> & HOCOptions = {}
): HOCType<P, K> {
const loadable = getLoadable(loaderFunction);
let loadable = getLoadable(loaderFunction);

const Imported = React.forwardRef<any, any>(function ImportedComponentHOC({ importedProps = {}, ...props }, ref) {
const options = { ...baseOptions, ...importedProps };
// re-get loadable in order to have fresh reference
loadable = getLoadable(loaderFunction);

return (
<ImportedComponent
Expand All @@ -49,7 +51,11 @@ function loader<P, K = P>(

return loadable.resolution;
};
Imported.done = loadable.resolution;
Object.defineProperty(Imported, 'done', {
get() {
return loadable.resolution;
},
});

return Imported;
}
Expand Down

0 comments on commit 8144a9f

Please sign in to comment.