react Suspense 异步交互

//将react组件由同步更新变为可阻断段的异步更新 解决cup瓶颈
import React, { Suspense } from 'react'
const Standard = React.lazy(()=>slowImport(import('./standard/standard'),1000))
const slowImport=(value, ms = 1000)=>{
     return new Promise(resolve=>{
         setTimeout(()=> resolve(value),ms);
     })
 }
//slowImport 方法模拟异步请求 加载数据
function Auth(props){
return(
 Loading...
}>
//section 可写可不写
) } // 配套的hook - [useDeferredValue]

你可能感兴趣的:(react Suspense 异步交互)