Как мы можем установить React Select Treating
import React from "react";
import { Form, Select, Button } from "antd";
import "./styles.css";
import "antd/dist/antd.css";
const { Option } = Select;
const AppWithForm = props => {
const { getFieldDecorator } = props.form;
const handleSubmit = () => {
props.form.validateFields((err, values) => {
if (!err) {
console.log("Received values of form: ", values);
} else console.log("form is NOT valid");
});
};
const onChange = value => {
console.log(`selected ${value}`);
};
return (
<div className="App">
<Form layout="inline">
<Form.Item>
{getFieldDecorator("dropdown", {
rules: [{ required: true, message: "Please select a person!" }]
})(
<Select
showSearch={false}
style={{ width: 200 }}
placeholder="Select a person"
optionFilterProp="children"
onChange={onChange}
>
<Option value="jack">Jack</Option>
<Option value="lucy">Lucy</Option>
<Option value="tom">Tom</Option>
</Select>
)}
</Form.Item>
<Form.Item>
<Button type="primary" onClick={handleSubmit}>
Save
</Button>
</Form.Item>
</Form>
</div>
);
};
const App = Form.create({})(AppWithForm);
export default App;
Cautious Caiman