L
L
lexstile2020-12-10 17:38:26
JavaScript
lexstile, 2020-12-10 17:38:26

How to optimize live search?

There is an array of objects of the form:

[
    {
      code: 'test',
      name: 'Тест',
    }
    // ...........
  ]

I make a filter on it, for example:
options.filter(({ name }) => name.includes(inputValue));

I bet on onChange input.
But due to the large volume (about 200 elements), it slows down.
Is there any way to optimize this process?
Perhaps some functions for finding a substring in a string are faster than includes ?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Lewandowski, 2020-12-10
@lexstile

You need debounce. For example, from lodash- lodash.com/docs/#debounce .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question