mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
- Convert Autosuggest component to a generic - Update the renderSuggestionsContainer signature - Add readme with usage example - Document component props - Export function types for easier reuse/passing in as props
914 B
914 B
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