lucaong / react-minisearch

React integration for the MiniSearch client side full-text search library
MIT License
48 stars 8 forks source link

In development react re-renders at least twice (sometimes even more) so useMiniSearch hook throws an error for ID duplication #35

Closed iamrakhmatov closed 1 year ago

iamrakhmatov commented 1 year ago

const miniSearchOptions = { fields: ['title'] };

function Products() { const { search, searchResults } = useMiniSearch(data, miniSearchOptions);

const handleSearchChange = (event: React.ChangeEvent) => { search(event.target.value); };

Screen Shot 2022-12-05 at 8 59 44 PM

It means I cannot use hook with React.StrickMode ?

lucaong commented 1 year ago

Hi @iamrakhmatov , thanks for reporting this! The issue should be fixed by https://github.com/lucaong/react-minisearch/pull/31 , which was just merged and released as v6.0.2.

qin-guan commented 1 year ago

Hey, it appears that there is a regression in the latest v6.0.3 release and this issue is occurring again

lucaong commented 1 year ago

Thanks @qin-guan , v6.0.4 (just released on NPM) should fix it, could you confirm?

qin-guan commented 1 year ago

Can confirm it works, thanks! 🙏🏻