I am trying to implement a table and do filtering and searching of data from the table. Since the searching and sorting takes a while I would like to implement a spinner display to show that the search/filtering is running.
Below is how I have implemented the component, I call filterData/ searchData to search through the data and return the results which is passed as props to the Grid Table component and where the data is displayed.
{this.state.search && this.state.filter &&
<GridTable
results= {filterData(this.state.filter,searchData(this.state.search,this.state.Data))}
/>}
{ this.state.search && !this.state.filter &&
<GridTable
results = {searchData(this.state.search,this.state.Data)}
/>}
{ !this.state.search && this.state.filter &&
<GridTable
results= {filterData(this.state.filter,this.state.Data)}
/>}
{ !this.state.search && !this.state.filter &&
<GridTable
results = {this.state.Data}
/>}
Where should i implement a loading state and set its state? I am confused since I am directly passing the result of the search/ filter functions into the props.