DefinitelyTyped/types/react-autosuggest
Thomas den Hollander d13cc8f363 [react-autosuggest] Make suggestions readonly (#35135)
This PR makes suggestions a `ReadonlyArray`. This is a less strict requirement and should be a backwards-compatible change. The suggestions property is not modified in the component.

This change allows usage in components that themselves only have access to a `ReadonlyArray`.
2019-05-13 10:15:27 -07:00
..
index.d.ts
react-autosuggest-tests.tsx
README.md
tsconfig.json
tslint.json

react-autosuggest usage notes

The definition uses generics for stronger typing. Read the TypeScript deep dive on JSX Generic components for details on consuming these type definitions.

Example

import * as Autosuggest from 'react-autosuggest'
interface Language {
    name: string
    year: number
}

const LanguageAutosuggest = Autosuggest as { new (): Autosuggest<Language> }

<LanguageAutosuggest
    suggestions={suggestions}
    onSuggestionsFetchRequested={this.onSuggestionsFetchRequested.bind(this)}
    getSuggestionValue={this.getSuggestionValue}
    renderSuggestion={this.renderSuggestion}
    onSuggestionSelected={this.onSuggestionsSelected}
    alwaysRenderSuggestions={true}
    inputProps={inputProps}
    theme={theme}
/>

Find multiple full examples in react-autosuggest-tests.tsx