import React from 'react'
import { Preloader } from 'src/base-components/preloader'
import styles from './styles.scss'
const withLazyLoading = (importComponent: any) => {
return class extends React.Component {
public state = {
component: null
}
public componentDidMount() {
importComponent()
.then((cmp) => {
this.setState({ component: cmp.default })
})
}
public render() {
const Component = this.state.component
return Component
? <Component { ...this.props } />
: <div className={ styles.box }><Preloader show /></div>
}
}
}
export { withLazyLoading }
我想添加类型:
importComponent: any <= not to be any
一切正常,但any
会导致错误: