react之lazy和Suspense

443 阅读1分钟

Suspense

以防其组件树中的某些子组件尚未具备渲染条件,显示fallback的内容

const Some = React.lazy(()=> import('./Some'));

class MyComponent extends React.PureComponent {
    render(){
        return (
            <React.Suspense fallback={<Loading/>}>
                <Some></Some>
            </React.Suspense>
        )
    }
}