Answers for "react select npm"

2

react select npm

import React from 'react';
import Select from 'react-select';

const options = [
  { value: 'chocolate', label: 'Chocolate' },
  { value: 'strawberry', label: 'Strawberry' },
  { value: 'vanilla', label: 'Vanilla' },
];

class App extends React.Component {
  state = {
    selectedOption: null,
  };
  handleChange = selectedOption => {
    this.setState({ selectedOption });
    console.log(`Option selected:`, selectedOption);
  };
  render() {
    const { selectedOption } = this.state;

    return (
      <Select
        value={selectedOption}
        onChange={this.handleChange}
        options={options}
      />
    );
  }
}
Posted by: Guest on March-02-2021
0

react select npm

yarn add react-select
npm i react-select
Posted by: Guest on July-11-2021
1

react select npm

yarn add react-select
Posted by: Guest on July-31-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language