Skip to content

Commit

Permalink
avoid re-creating Fallback and LazyComponent in asyncComponentLoader
Browse files Browse the repository at this point in the history
  • Loading branch information
suren-atoyan committed Dec 11, 2020
1 parent 4561d76 commit eb9ef72
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/utils/asyncComponentLoader/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,17 +104,17 @@ function asyncComponentLoader(
FallbackWaiting,
FallbackFail,
) {
return function AsyncComponent(props) {
const Fallback = loaderOptions.delay
? getDelayedFallback(FallbackWaiting, loaderOptions.delay)
: FallbackWaiting;

const LazyComponent = getLazyComponent(
loadComponent,
loaderOptions,
FallbackFail,
);
const Fallback = loaderOptions.delay
? getDelayedFallback(FallbackWaiting, loaderOptions.delay)
: FallbackWaiting;

const LazyComponent = getLazyComponent(
loadComponent,
loaderOptions,
FallbackFail,
);

return function AsyncComponent(props) {
return (
<Suspense fallback={<Fallback />}>
<LazyComponent {...props} />
Expand Down

0 comments on commit eb9ef72

Please sign in to comment.