Git Product home page Git Product logo

react-native-autocomplete-input's Introduction

react-native-autocomplete-input

npm version Build Status

This is a pure javascript react-native component to display autocomplete suggestions given an array of objects respective to the input text.

Autocomplete Example

How to use react-native-autocomplete-input

Tested with RN >= 0.26.2. If you want to use RN < 0.26 try to install react-native-autocomplete-input <= 0.0.5.

First things first install the component from npmjs.org:

$ npm install --save react-native-autocomplete-input

or install HEAD from github.com:

$ npm install --save l-urence/react-native-autocomplete-input

Android

On Android please install the v.1.1.2 release. The v2.0.0 release don’t show the suggestion list correctly because RN for Android doesn’t support overflows (see #20).

$ npm install --save [email protected]

Example

This brief example should illustrate the usage of the autocomplete:

// ...
render() {
  const { query } = this.state;
  const data = this._filterData(query)
  <Autocomplete
    data={data}
    defaultValue={query}
    onChangeText={text => this.setState({query: text})}
    renderItem={data => (
      <TouchableOpacity onPress={() =>
          this.setState({query: data})
        }
      >
        <Text>{data}</Text>
      </TouchableOpacity>
    )}
  />
}
// ...

The full example from the screenshot can be found here

react-native-autocomplete-input props

Prop Type Description
containerStyle style These styles will be applied to the container which surrounds the autocomplete component.
inputContainerStyle style These styles will be applied to the container which surrounds the textInput component.
style style These styles will be applied to the textInput component.
data array Assign an array of data objects which should be rendered in respect to the entered text.
listStyle style These style will be applied to the result list view.
renderItem function renderItem will be called to render the data objects which will be displayed in the result view below the text input.
renderSeparator function renderSeparator will be called to render the list separators which will be displayed between the list elements in the result view below the text input.
onShowResult function onShowResult will be called when the autocomplete suggestions appear or disappear.
renderTextInput function render custom TextInput. All props passed to this function.

Contribute

Feel free to open issues or do a PR!

react-native-autocomplete-input's People

Contributors

eliseo-juan avatar huszy avatar jasontwong avatar kesha-antonov avatar mrlaessig avatar szajbus avatar vonovak avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.