import React , { Component } from 'react' ; import AsyncSelect from 'react-select/async' ; import { ColourOption , colourOptions } from '../data' ; const filterColors = ( inputValue ) => { return colourOptions . filter ( ( i ) => i . label . toLowerCase ( ) . includes ( inputValue . toLowerCase ( ) ) ) ; } ; const promiseOptions = ( inputValue ) => new Promise < ColourOption [ ] > ( ( resolve ) => { setTimeout ( ( ) => { resolve ( filterColors ( inputValue ) ) ; } , 1000 ) ; } ) ; export default class WithPromises extends Component { render ( ) { return ( < AsyncSelect cacheOptions defaultOptions loadOptions = { promiseOptions } / > ) ; } }