0.0.4 • Published 7 years ago

@factorbi/component-autocomplete v0.0.4

Weekly downloads
-
License
ISC
Repository
bitbucket
Last release
7 years ago

React component

How to use

Installation

> npm i @factorbi/component-autocomplete

Component

Example:

import Autocomplete from '@factorbi/component-autocomplete';

export default class Reports extends React.Component {

    constructor() {
        this.state = {
            client: undefined,
            // When api is call, here an example data:
            arrClientData: [
                {id: 941, value:'Estudiantes de Primaria'},
                {id: 945, value:'Estudiantes de … técnico'},
                {id: 949, value:'Estudiantes de …versidad'}
            ]
        };
        this.handleAutocomplete = this.handleAutocomplete.bind(this);
        this.handleGetValue = this.handleGetValuer(this);
    }

    handleAutocomplete(e) {
        const { value, name } = e.target;
        // Here call api
        // example line: this.props.dispatch(actions.getStringSearch(jwt, value, name));
    }

    handleGetValue(name, value) {
        this.setState({ [name]: value });
    }

    render() {
        return (
            <Autocomplete
                id="inputClients"
                idList="slcClients"
                name="client"
                minimum={ 3 }
                label="Clients"
                dataType="client"
                placeholder="Search clients"
                data={ this.state.arrClientData }
                onChange={ this.handleAutocomplete }
                onGetValue={ this.handleGetValue }
            />
        );
    }
}
0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago