SAMPLE NODE SCRIPT: (works)
const Fuse = require('fuse.js');
const pathTotags = 'value';
const config = {
id: pathTotags,
shouldSort: true,
threshold: 0.6,
location: 0,
distance: 100,
maxPatternLength: 32,
minMatchCharLength: 1,
keys: [pathTotags],
};
const list = [
{ value: 'ajnckajfn' },
{ value: 'ajnsdfasldkckajfn' },
{ value: 'o;ip09ksd' },
{ value: ' xkln' },
{ value: 'uwerh' },
{ value: 'sdk;fmsdl;km' },
];
const fuse = new Fuse(list, config);
const result = fuse.search('a');
console.log(result);
// console.log('help');
I have this set up in React Native in the same way with no results returned, but also no errors, either.
always returns an empty array in RN
ah, it is because it was inside of a mobX class. evidently it doesn't work with the observableArray there
for anyone else with this issue, use this: https://mobx.js.org/refguide/tojson.html
I believe you may close this issue if everything has been sorted out.
It is not working @atljoseph. My array is already non-observable.
I just ran into this, and it was a result of me screwing up, so I figured I'd put it here for posterity in case anyone else runs into this.
I was using Redux to fetch my items, but was instantiating the Fuse search in componentDidMount. That meant when it got instantiated, redux hadn't finished populating all of my items, so Fuse was searching on an empty list. The solution was to make sure that I reinstantiated Fuse when the component got new items from Redux in componentDidUpdate.
One of those silly things you're bound to forget when prototyping quickly. Hope this helps someone.
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days
Most helpful comment
I just ran into this, and it was a result of me screwing up, so I figured I'd put it here for posterity in case anyone else runs into this.
I was using Redux to fetch my items, but was instantiating the Fuse search in
componentDidMount. That meant when it got instantiated, redux hadn't finished populating all of my items, so Fuse was searching on an empty list. The solution was to make sure that I reinstantiated Fuse when the component got new items from Redux incomponentDidUpdate.One of those silly things you're bound to forget when prototyping quickly. Hope this helps someone.