关于以下代码说法错误的是 const OtherComponent = React.lazy(() => import(‘./OtherComponent’)); function MyComponent() {      return (               <>                             <React.Suspense fallback={<Component1 />}>                                              <div>                                                                   <OtherComponent />                                             </div>                                           </React.Suspense>                        </>            );  }

区块链毕设网qklbishe.com为您提供问题的解答

关于以下代码说法错误的是

const OtherComponent = React.lazy(() => import('./OtherComponent')); function MyComponent() {      return (               <>                             <React.Suspense fallback={<Component1 />}>                                              <div>                                                                   <OtherComponent />                                             </div>                                           </React.Suspense>                        </>            );  } 

答案: C

lazy 懒加载组件, 经常和React的Suspense 组件搭配使用 , 常用于渲染异步组件,可以做加载动画,代码拆分 , 用于加载完之前先渲染一个加载动画或者占位符 (骨架屏)

A. React.lazy()定义一个动态加载的组件OtherComponent

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

B. 同A, OtherComponent组件是动态加载的

C. X, OtherComponent加载完成前,显示的是<Component1>组件,加载完之后才显示 <OtherComponent />

D. 同A

  • 组件切换时,加载新的组件代码,代码加载是异步的过程
  • suspense就会进入fallback,那我们看到的就是<Component1>
  • 显式的告诉用户正在加载,当代码加载完成就会展示<OtherComponent />组件的内容
59:12

以上就是关于问题关于以下代码说法错误的是 const OtherComponent = React.lazy(() => import(‘./OtherComponent’)); function MyComponent() {      return (               <>                             <React.Suspense fallback={<Component1 />}>                                              <div>                                                                   <OtherComponent />                                             </div>                                           </React.Suspense>                        </>            );  }的答案

欢迎关注区块链毕设网-
专业区块链毕业设计成品源码,定制。

区块链NFT链游项目方科学家脚本开发培训

从业7年-专注一级市场


微信:btc9767
TELEGRAM :https://t.me/btcok9

具体资料介绍

web3的一级市场千万收益的逻辑


进群点我



qklbishe.com区块链毕设代做网专注|以太坊fabric-计算机|java|毕业设计|代做平台-javagopython毕设 » 关于以下代码说法错误的是 const OtherComponent = React.lazy(() => import(‘./OtherComponent’)); function MyComponent() {      return (               <>                             <React.Suspense fallback={<Component1 />}>                                              <div>                                                                   <OtherComponent />                                             </div>                                           </React.Suspense>                        </>            );  }