You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If I add the lazy load function <DataTable onLazyLoad={this.onLazyLoad} ....> it repeatedly calls the function causing an infinite loop/timeout.
I don't have to do or click anything. It just keeps on going :)
Here's my example using redux to get the data
/* @flow */importReact,{Component}from'react';importPropTypesfrom'prop-types';// Reduximport{connect}from'react-redux';import{loadStreamEvents}from'store/actions/stream/StreamActions';// prime uiimport{DataTable}from'primereact/components/datatable/DataTable';import{Column}from'primereact/components/column/Column';import{InputText}from'primereact/components/inputtext/InputText';// UiimportPageTemplatefrom'app/components/templates/page.template';importReloadCountdownfrom'app/components/molecules/ReloadCountdown/ReloadCountdown';importFullHeightfrom'app/components/atoms/FullHeight/FullHeight';importButtonIconfrom'app/components/molecules/ButtonIcon/ButtonIcon';importLoaderfrom'app/components/atoms/Loader/Loader';/** * Renders the view to display the things. */classTestPrimeDataTableextendsComponent<Object,Object>{staticpropTypes={loadStreamEvents: PropTypes.func.isRequired,isLoading: PropTypes.bool.isRequired,list: PropTypes.array,};loadParams: Object;state: Object;thisGrid: any;onLazyLoad: Function;loadData: Function;/** * @param props the Component's properties */constructor(props: Object): void{super(props);this.state={gridVersion: 0,params: {page: 1,pageSize: 10,continuousScrolling: false,maxCount: 1000,orderBy: [],where: [],}};this.onLazyLoad=this.onLazyLoad.bind(this);this.loadData=this.loadData.bind(this);}/** * Load events when component mounts */componentDidMount(){this.props.loadStreamEvents(this.state.params);}/** * Data load function */loadData(){this.props.loadStreamEvents(this.state.params);}/** * Call function for server side filtering * @param event */onLazyLoad(event){// this.refreshGrid();/* In a real application, make a remote request to load data using state metadata from event * event.first = First row offset * event.rows = Number of rows per page * event.sortField = Field name to sort with * event.sortOrder = Sort order as number, 1 for asc and -1 for dec * filters: FilterMetadata object having field as key and filter value, filter matchMode as value *//*setTimeout(() => { this.props.loadStreamEvents(this.state.params); }, 250); */console.log('Event',event);constpage=this.state.params&&this.state.params.page<=0 ? 1 : (event.first/event.rows)+1;constsortOrder=(event.sortOrder&&event.sortOrder===1);constorderBy=[{field: event.sortField,asc: sortOrder},event.multiSortMeta];// TODO: Multifltersconstwhere=[];this.setState({params: {
page,
orderBy,
where
}});console.log('StateParams',this.state.params);// CALLING ANYTHING HERE CAUSES INFINITE LOOP// this.props.loadStreamEvents(this.state.params);// this.loadData();}exportData=()=>{this.thisGrid.exportCSV();};/** * @override */render(): Object{const{ list, isLoading }=this.props;constcols=[{field: 'id',header: 'ID'},{field: 'status',header: 'Status'},{field: 'severity',header: 'Severity'},{field: 'impact',header: 'Impact'},{field: 'data_description',header: 'Description'},{field: 'thing_id',header: 'Thing name'},{field: 'event_id',header: 'Event ID'},];constdynamicColumns=cols.map((col,i)=>{return<Columnkey={col.field}field={col.field}header={col.header}filtersortable/>;});constheader=<divstyle={{textAlign: 'center'}}><InputTexttype="search"onInput={(e)=>this.setState({globalFilter: e.target.value})}placeholder="Global Search"size="100"/><ButtonIconicon="file-export"onClick={this.exportData}/><ReloadCountdowndisableCountdown={isLoading}seconds={180}format={'minutes'}action={this.refreshGrid}/></div>;if(isLoading){return<Loaderabsolute/>;}return(<PageTemplatetitle="Events DT"><FullHeight><DataTablestyle={{fontSize: '14px'}}ref={(el)=>{this.thisGrid=el;}}header={header}value={list}rows={this.state.params.pageSize||10}totalRecords={this.state.params.maxCount||1000}// scrollable// scrollHeight="600"lazyonLazyLoad={this.onLazyLoad}sortMode="multiple"paginatorresponsive>{dynamicColumns}</DataTable></FullHeight></PageTemplate>);}}constmapStateToProps=(state)=>{return{isLoading: state.stream.streams.isLoading,list: state.stream.streams.list,};};constmapDispatchToProps=()=>{return{
loadStreamEvents
};};exportdefaultconnect(mapStateToProps,mapDispatchToProps())(TestPrimeDataTable);
The text was updated successfully, but these errors were encountered:
I'm going to close this as I fixed the infinite loop via removing the isLoading from before the grid render. Maybe having the grid with it's own loading state would be helpful.
If I add the lazy load function <DataTable onLazyLoad={this.onLazyLoad} ....> it repeatedly calls the function causing an infinite loop/timeout.
I don't have to do or click anything. It just keeps on going :)
Here's my example using redux to get the data
The text was updated successfully, but these errors were encountered: