i have the following
<Async
autoload={false}
multi={false}
value={this.state.selectValue}
onChange={this.updateValue}
valueKey="value"
labelKey="label"
loadOptions={this.getCommsmatrices}
onValueClick={this.gotoCommsmatrix}
cache={false}
/>
getCommsmatrices (input, callback) {
input = input.toLowerCase();
let options = this.state.options.filter(i => {
return i.label.toLowerCase().includes(input) == true;
});
let data = {
options: options,
complete: true
};
setTimeout(function() {
callback(null, data);
}, ASYNC_DELAY);
}
once my results are loaded it stays cached. i want to trigger this cache clean externally. how can this be done?
i want to clear the cache in the following function. I have tried setting isLoading but it does not work.
updateCommsMatrix(service_id){
this.setState({ isLoading: true });
this.updateValue(null);
if(service_id > 0){
let self = this;
this.props.fetchCommsmatricesByService(service_id)
.then( response => {
let data = response.payload.data.body.recordset.record;
let options = self.populateOptionsObject(data, 'id', 'filename');
options.unshift({ value: '0', label: 'All' });
return options;
})
.then( options => self.setState({options:options,isLoading: false}));
} else {
this.setState({ options:{ value: '0', label: 'All'},isLoading: false });
}
this.props.dispatch(change('SecurityExemptionsNewForm', 'service_id', service_id));
}
I'm also struggling with the @shorif2000 -
I'm trying am trying to create a filter list where if the user has typed more than 3 letters, but no results are returned, we show them the full list of options.
I believe the problem is not in cache but rather that the callback is always returning the filtered result
https://github.com/JedWatson/react-select/blob/99acc31346acacaee23cefecd2ab9b13e3d672bb/src/Async.js#L99
Looking here, my reading is that the cache is always being used and I'm picturing the cache as an object, which holds the keys of everything which has been entered. I haven't tracked down where the options creates the list of results yet.
I thought I'd post here and see if you've had any luck or maybe we can help each other out.
@shorif2000 @pedalpete could you specify which version of react-select you are using?
I'm on 1.2.1
@JedWatson im on 1.2.1
Possibly related to #2661
@JedWatson I'm using v2, please advise on how to clear the cache on this version. Thanks!
Hello -
In an effort to sustain the react-select project going forward, we're closing old issues.
We understand this might be inconvenient but in the best interest of supporting the broader community we have to direct our efforts towards the current major version.
If you aren't using the latest version of react-select please consider upgrading to see if it resolves any issues you're having.
However, if you feel this issue is still relevant and you'd like us to review it - please leave a comment and we'll do our best to get back to you!