Skip to content
Snippets Groups Projects
Commit 23e854cb authored by Sorin Davidoi's avatar Sorin Davidoi Committed by Eugen Rochko
Browse files

fix(components/bundle): Exit early in load function (#4349)

parent de105d64
No related branches found
No related tags found
No related merge requests found
......@@ -52,14 +52,8 @@ class Bundle extends React.Component {
load = (props) => {
const { fetchComponent, onFetch, onFetchSuccess, onFetchFail, renderDelay } = props || this.props;
this.setState({ mod: undefined });
onFetch();
if (renderDelay !== 0) {
this.timestamp = new Date();
this.timeout = setTimeout(() => this.setState({ forceRender: true }), renderDelay);
}
if (Bundle.cache[fetchComponent.name]) {
const mod = Bundle.cache[fetchComponent.name];
......@@ -68,6 +62,13 @@ class Bundle extends React.Component {
return Promise.resolve();
}
this.setState({ mod: undefined });
if (renderDelay !== 0) {
this.timestamp = new Date();
this.timeout = setTimeout(() => this.setState({ forceRender: true }), renderDelay);
}
return fetchComponent()
.then((mod) => {
Bundle.cache[fetchComponent.name] = mod;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment