Skip to content

iegik/react-autocomplete

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

react-autocomplete

Select container with autocomplete list and search method

Install

npm install react-autocomplete-field

Usage

import React from 'react';
import {Select, List, ListItem, TextInput} from 'react-autocomplete-field';
import {getCountrySuggestions} from '../../api/ddata-api';

class CountryAutocomplete extends Select {
    renderInput = TextInput;

    renderAutocomplete = List;

    renderAutocompleteItem = ListItem;

    // This will fill `items` property while typing
    search = text => getCountrySuggestions(text).then(({suggestions}) => suggestions);

    // This is for getting values from each suggestion
    getSuggestionValue = item => item.value;
}
export default CountryAutocomplete;

Props

  • value - as in usual input
  • onSelect - fires when value was chosen from list
  • onChange - fires while value changes, as you type
  • onError - fires when error was thrown in search method

About

Input container with autocomplete

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published