Я хочу использовать lunr js в приложении реагирования для поиска строк, но я не знаю, как настроить лунный индекс. в документации написано The Lunr index. This can be an instance of a Lunr index or one that has been exported via JSON.stringify. The Lunr index. This can be an instance of a Lunr index or one that has been exported via JSON.stringify. но я не знаю, как это сделать.

 import React, { useState } from 'react' import { useLunr } from 'react-lunr' import { Formik, Form, Field } from 'formik' const index = /* a lunr index */ const store = { 1: { id: 1, title: 'Document 1' }, 2: { id: 2, title: 'Document 2' }, 3: { id: 3, title: 'Document 3' }, } const SearchBar = () ={amp}gt; { const [query, setQuery] = useState(null) const results = useLunr(query, index, store) return ( {amp}lt;Formik initialValues={{ query: '' }} onSubmit={(values, { setSubmitting }) ={amp}gt; { setQuery(values.query) setSubmitting(false) }} {amp}gt; {amp}lt;Form{amp}gt; {amp}lt;Field name="query" /{amp}gt; {amp}lt;/Form{amp}gt; {amp}lt;h1{amp}gt;Results{amp}lt;/h1{amp}gt; {amp}lt;ul{amp}gt; {results.map(result ={amp}gt; ( {amp}lt;li key={result.id}{amp}gt;{result.title}{amp}lt;/li{amp}gt; ))} {amp}lt;/ul{amp}gt; {amp}lt;/Formik{amp}gt; ) }