Open timmeno1 opened 1 year ago
Hi @timmeno1 ,
are you using TypeScript? If so, you might need to set the esModuleInterop option to true
in the compilerOptions
section of tsconfig.json
.
I have the same problem with v5.0.0 (v5.0.0-beta1 is working fine), my esModuleInterop
flag is already true
😢
Uncaught TypeError: MiniSearch__default.default is not a constructor
at useMiniSearch (react-minisearch.tsx:23:1)
Same issue with 5.0.0-beta2
, https://github.com/lucaong/minisearch/commit/39d269740fd21fc46b3980c916fd35bf49acfe77 must be the culprit
What is strange is that the examples in this repo are working fine, and so the projects where I use this library. I think I need some more info to debug this. For example, how do you import react-minisearch
?
Are you using the https://create-react-app.dev/?
import { useMiniSearch } from 'react-minisearch';
export const MyComponent: React.FC = () => {
...
const { search, searchResults, addAll, removeAll } = useMiniSearch<{
id: string;
name: string;
}>([], {
fields: ['name'],
storeFields: ['name'],
searchOptions: { prefix: true },
});
...
}
I don’t, but I can try it to reproduce the issue
I am also facing the same issue with version 6.0.2
, and esModuleInterop is also true
Hello, i'm caused by "Uncaught TypeError: MiniSearch__default.default is not a constructor" when just trying to initialize const { search, searchResults } = useMiniSearch(documents, miniSearchOptions) doing same as provided in examples. May be i'm doing wrong? p.s. sorry for my english