My input data is in Array format like ["A","B","C"] and i would like to display them as options in react-select.
import React, { Component } from 'react';
import Select from 'react-select';
const test= ["a","b","c"]
class TestSelect extends React.Component {
state = {
multi: null,
};
handleChange = name => value => {
this.setState({
[name]: value,
});
};
render() {
return (
<div className='dropdown' style={{ dispay: 'inline-block', width: 250, paddingLeft: 50, paddingTop: 50 }}>
<Select
options={test}
value={this.state.multi}
autosize={true}
onChange={this.handleChange('multi')
isMulti
placeholder="Select Values"
/>
</div >
);
}
}
export default TestSelect;
Is it possible to use the array as option or it is always should be a object?
const options = [ { value: 'chocolate', label: 'Chocolate' }, { value: 'strawberry', label: 'Strawberry' }, { value: 'vanilla', label: 'Vanilla' } ];