0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2025-02-24 23:55:46 -05:00

fix: broken home page

This commit is contained in:
Juan Picado @jotadeveloper 2019-01-09 23:41:34 +01:00
parent 236cc9530b
commit 4f41fc94e2
No known key found for this signature in database
GPG key ID: 18AC54485952D158

View file

@ -1,26 +1,27 @@
import React from 'react'; import React from 'react';
export function asyncComponent(getComponentFunc) { export function asyncComponent(getComponent) {
return class AsyncComponent extends React.Component { return class AsyncComponent extends React.Component {
static Component = null; static Component = null;
state = {Component: this.getComponent()}; state = {Component: AsyncComponent.Component};
getComponent() { componentDidMount() {
if (!AsyncComponent.Component) { const {Component} = this.state;
getComponentFunc().then(({default: Component}) => {
if (!Component) {
getComponent().then(({default: Component}) => {
AsyncComponent.Component = Component; AsyncComponent.Component = Component;
return Component; /* eslint react/no-did-mount-set-state:0 */
this.setState({Component});
}); });
} }
return AsyncComponent.Component;
} }
render() { render() {
const {Component} = this.state; const {Component} = this.state;
if (Component) { if (Component) {
return <Component {...this.props} />; return <Component {...this.props} />;
} }
return null; return null;
} }
}; };