简体   繁体   中英

Filtering long lists take a long time to run

I have a Dropdown with about 7000 objects. I have tried using semantic-ui react components but it still takes a long time to search and get results.

My copyList contains all the options and the filteredCopyList is what is rendered in the dropdown onKeyUp. Is it going slow due to rendering a long list of items and filtering them at the same time?

//list of 7000
const copyList = [
    {itemDesc: 'itemDesc1', shortDesc: 'shortDesc1'}
]


filterList = () => {
    const re = new RegExp(_.escapeRegExp(this.state.searchCopyList),'i');
    const isMatch = result => (re.test(result.shortDesc) || 
    re.test(result.itemDesc));
    this.setState({
        filteredCopyList: _.filter(this.state.copyList, isMatch)
    });
}

You can try with the following package of npm:

Infinite Scrolling package

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM