npm install basic-react-dropdown
import React, { useState } from "react";
import Dropdown from "basic-react-dropdown";
function Form() {
const [department, setDepartment] = useState('');
const onEditDepartment = (value) => {
setDepartment(value);
}
const departmentOptions = [
{ value: 'Sales', label: 'Sales' },
{ value: 'Marketing', label: 'Marketing' },
{ value: 'Engineering', label: 'Engineering' },
{ value: 'Human Resources', label: 'Human Resources' },
{ value: 'Legal', label: 'Legal' },
];
return (
<Dropdown options={departmentOptions} onChange={onEditDepartment} value={department}/>
)
}
export default Form;| Name | Type | Description |
|---|---|---|
| options | array | Array of object with value and label as property |
| onChange | function | Launch function when user select value |
| value | string | Display value of selected option |
npm run start
npm run test
