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:
parent
236cc9530b
commit
4f41fc94e2
1 changed files with 10 additions and 9 deletions
|
@ -1,26 +1,27 @@
|
|||
import React from 'react';
|
||||
|
||||
export function asyncComponent(getComponentFunc) {
|
||||
export function asyncComponent(getComponent) {
|
||||
return class AsyncComponent extends React.Component {
|
||||
static Component = null;
|
||||
state = {Component: this.getComponent()};
|
||||
state = {Component: AsyncComponent.Component};
|
||||
|
||||
getComponent() {
|
||||
if (!AsyncComponent.Component) {
|
||||
getComponentFunc().then(({default: Component}) => {
|
||||
componentDidMount() {
|
||||
const {Component} = this.state;
|
||||
|
||||
if (!Component) {
|
||||
getComponent().then(({default: Component}) => {
|
||||
AsyncComponent.Component = Component;
|
||||
return Component;
|
||||
/* eslint react/no-did-mount-set-state:0 */
|
||||
this.setState({Component});
|
||||
});
|
||||
}
|
||||
|
||||
return AsyncComponent.Component;
|
||||
}
|
||||
|
||||
render() {
|
||||
const {Component} = this.state;
|
||||
if (Component) {
|
||||
return <Component {...this.props} />;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue