mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
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`. |
||
|---|---|---|
| .. | ||
| 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