import React from "react"; import styles from "./index.less"; import { Mentions, Form, Button } from "antd"; const { Option, getMentions } = Mentions; class App extends React.Component { handleReset = e => { e.preventDefault(); this.props.form.resetFields(); }; handleSubmit = e => { e.preventDefault(); this.props.form.validateFields((errors, values) => { if (errors) { console.log("Errors in the form!!!"); return; } console.log("Submit!!!"); console.log(values); }); }; checkMention = (rule, value, callback) => { const mentions = getMentions(value); if (mentions.length < 2) { callback(new Error("More than one must be selected!")); } else { callback(); } }; render() { const { form: { getFieldDecorator } } = this.props; return (
{getFieldDecorator("coders", { rules: [{ validator: this.checkMention }] })( )} {getFieldDecorator("bio", { rules: [{ required: true }] })( )}    
); } } const FormDemo = Form.create()(App); export default () => (
);