feat: remove store parameter
BREAKING CHANGE: store parameter has been removed. Map results in your component if necessary.
Reasoning
Some indexes are configured to return just an ID as a result. This requires you to map the ID to your data.
Some indexes are configured to return the whole document as a result. This does not require you to map any data.
The hook previously would handle mapping for you, but doing so removed the ability to configure your FlexSearch index to return the whole document by default. This PR removes the store functionality altogether and leaves it up to the user to map the results if necessary.
Upgrade Path
If you relied on the store mapping functionality, map the results in your component:
import React, { useMemo } from 'react'
import { useFlexSearch } from 'react-use-flexsearch'
const Search = (query, index, store) => {
const results = useFlexSearch(query, index)
const mappedResults = useMemo(() => results.map(result => store[result]), [results])
return (
<ul>
{mappedResults.map(result => (
<li key={result.id}>{result.myField}</li>
)}
</ul>
)
}
See #2