Socket
Socket
Sign inDemoInstall

react-native-input-autocomplete

Package Overview
Dependencies
2
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    react-native-input-autocomplete

A simple and fully customizable React Native component that can be used for autocompletion when searching data from local or remote source.


Version published
Weekly downloads
5
Maintainers
1
Install size
678 kB
Created
Weekly downloads
 

Readme

Source

react-native-input-autocomplete

A simple and fully customizable React Native component that can be used for autocompletion when searching data from local or remote source.

Autocomplete Example

Installation

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

or

$ yarn add react-native-input-autocomplete

Usage

// ...


import React, { useState } from "react";
import { Autocomplete } from "react-native-input-autocomplete";

const ExampleApp = props => {

    const [isVisible, setIsVisible] = useState(false);
    const [addressOptions, setAddressOptions] = useState([]);

    const defaultOptions = [
        {
            id: "1",
            label: "Home",
            description: "200 Larkin St, San Francisco, CA 94102"
        },
        {
            id: "2",
            label:"Work",
            description: "1 Dr Carlton B Goodlett Pl, San Francisco, CA 94102"
        }
    ];

    const autocompleteInputHandler = async input => {
        const result = await fetch("http://example.com/address");
        const data = await result.json();
        setAddressOptions(data);
    };

    const selectValue = (value) => {
        // Value is whatever user selected in autocomplete.
    };

    render() {
        return (
            <Autocomplete 
                visible={isVisible}
                autocompleteOptions={addressOptions}
                defaultOptions={defaultOptions}
                dividerTitle={"Your Favourite Addresses"}
                onInputChange={autocompleteInputHandler}
                onSelect={selectValue}
                hideAutocomplete={() => setIsVisble(false)}
            />
        );
    }

};

// ...

Props

PropTypeDescription
visiblebooleanSet to true to show the component.
autocompleteOptionsarrayAn array with the list of suggested options.
defaultOptionsarrayAn array with the list of pre-saved favourite options.
dividerTitlestringA string that divides the suggested list from the default list.
onInputChangefunctionThe callback that will be called when the user starts typing in the input container.
onSelectfunctionThe callback that will be called once the user selects an option from the autocomplete suggestions.
hideAutocompletefunctionThe callback hides the autocomplete component.

Contribute

Feel free to open issues or do a PR!

Keywords

FAQs

Last updated on 28 Jan 2020

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc