gpt4 book ai didi

javascript - 如何在 react 表上实现延迟加载数据?

转载 作者:行者123 更新时间:2023-12-05 05:10:32 26 4
gpt4 key购买 nike

我正在获取大量数据,同时我想延迟加载 react 表

import React, {Component, Fragment, lazy, Suspense} from 'react'; 
const ReactTable = lazy(() => import("react-table"));
render()
{
return (
<Suspense fallback={<div>Loading...</div>}>
{this.state.securityCheck.length ?
<ReactTable columns={columns} data={this.state.securityCheck} />
:
<div className='text-center' style= {{fontSize: '20px'}}>No data =
Available! </div> }
</Suspense>
)
}

最佳答案

来自文档:

The fallback prop accepts any React elements that you want to render while waiting for the component to load. You can place the Suspense component anywhere above the lazy component. You can even wrap multiple lazy components with a single Suspense component.

试试这个,

<Suspense fallback={<div>Loading...</div>}> 
<ReactTable columns={columns} data={this.state.securityCheck} />
</Suspense>

关于javascript - 如何在 react 表上实现延迟加载数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56523107/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com