Async React-select with abbreviation

I am trying to create a shortcut async-react-select component, but somehow I can't get the search results in the dropdown. Very new to this. Please, help:)

import React, { PropTypes } from 'react';
import { Link } from 'react-router';
import { connect } from 'react-redux';
import Select from 'react-select';

import { fetchInstitutionsIfNeeded } from '../../actions/institutions';

class Signup extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            value: null
        };
        this.getInstitutions = this.getInstitutions.bind(this);
        this.onChange = this.onChange.bind(this);
    }

    onChange(input) {
        this.setState({
            value: input
        });
    }

    getInstitutions(input) {
        const { dispatch } = this.props;
        if (!input) {
            return Promise.resolve({ options: [] });
        }
        dispatch(fetchInstitutionsIfNeeded(input));
    }

    render() {
        let options = this.props.options;
        return (
            <div>
                <Select.Async
                    name="institute"
                    value={this.state.value}
                    autoload={false}
                    onChange={this.onChange}
                    loadOptions={this.getInstitutions}
                />
            </div>
        );
    }
}

const mapStateToProps = (state) => ({
    options: state.institutions.options
});

export default connect(mapStateToProps)(Signup);

      

Also the option object is also properly formatted and updated correctly in the redux store, but does not reflect it in the async dropdown.

+3


source to share





All Articles