javascript - How can I implement lazy loading of data on react table? - Stack Overflow

I'm featching large amount on data and meanwhile I want to lazy load the react tableimport React,

I'm featching large amount on data and meanwhile I want to lazy load the react table

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> 
) 
}

I'm featching large amount on data and meanwhile I want to lazy load the react table

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> 
) 
}
Share asked Jun 10, 2019 at 8:43 Parth ShrivastavaParth Shrivastava 311 gold badge1 silver badge6 bronze badges 1
  • 1 There are quite a few resources for this sort of thing online, I will leave one here: hackernoon./… In the mean time, please update your question with any specific issues you are getting as well as your current approach. – Mark Harwood Commented Jun 10, 2019 at 8:49
Add a ment  | 

1 Answer 1

Reset to default 2

From the Docs:

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

Try this,

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

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745098179a4611109.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信