ant-design/components/mention/demo/controllder-simple.md
陆离 05c6d09eab docs: add controllerd sample (#3504)
* add controllerd sample

* lint
2016-10-20 13:51:44 +08:00

655 B

order title
3
zh-CN en-US
受控模式 Controlled

zh-CN

受控模式.

en-US

Controlled mode.

import { Mention } from 'antd';
const { toEditorState } = Mention;

const App = React.createClass({
  getInitialState() {
    return {
      value: toEditorState('@afc163'),
    };
  },
  handleChange(editorState) {
    this.setState({
      value: editorState,
    });
  },
  render() {
    return (<Mention
      suggestions={['afc163', 'benjycui', 'yiminghe', 'RaoHai', '中文', 'にほんご']}
      value={this.state.value}
      onChange={this.handleChange}
    />);
  },
});

ReactDOM.render(<App />, mountNode);