2016-07-04 10:31:27 +08:00
---
category: Components
2016-11-09 14:43:32 +08:00
type: Data Entry
2016-09-08 16:53:50 +08:00
title: Mention
2016-07-04 10:31:27 +08:00
---
Mention component。
## When To Use
When need to mention someone or something.
2016-07-21 15:41:40 +08:00
## API
2016-07-21 15:23:04 +08:00
```jsx
< Mention
onChange={onChange}
suggestions={['afc163', 'benjycui', 'yiminghe', 'jljsj33', 'dqaria', 'RaoHai']}
/>
2016-07-04 10:31:27 +08:00
```
2016-07-20 18:56:44 +08:00
### Mention API
2016-07-21 15:23:04 +08:00
| API | Description | Type |
2016-07-20 18:56:44 +08:00
|----------|---------------|----------|--------------|
2017-01-20 20:10:50 +08:00
| toString | convert EditorState to string | Function(editorState: EditorState): string |
| toEditorState | convert string to EditorState | Function(value: string): EditorState |
| getMentions | get mentioned people in current editorState | Function(editorState: EditorState): string[] |
2016-07-20 18:56:44 +08:00
2016-07-04 10:31:27 +08:00
### Mention props
| Property | Description | Type | Default |
|----------|---------------|----------|--------------|
2017-01-20 20:10:50 +08:00
| suggestions | suggestion content | Array< string \|Mention.Nav > | [] |
| suggestionStyle | style of suggestion container | object | {} |
2017-02-13 15:50:38 +08:00
| onSearchChange | Callback function called when search content changes | function(value:string, trigger: string) | [] |
2016-07-19 13:39:05 +08:00
| onChange | Callback function called when content of input changes | function(editorState: EditorState) | null |
2017-01-20 20:10:50 +08:00
| onSelect | Callback function called when select from suggestions | function(suggestion: string, data?: any) | null |
2016-07-04 10:31:27 +08:00
| notFoundContent| suggestion when suggestions empty | string | '无匹配结果,轻敲空格完成输入' |
| loading | loading mode | boolean | false |
| multiLines | multilines mode | boolean | false |
2017-02-13 15:50:38 +08:00
| prefix | character which will trigger Mention to show mention list | string or Array< string > | '@' |
2016-07-19 13:39:05 +08:00
| defaultValue | default value | EditorState, you can use `Mention.toEditorState` to convert text to `EditorState` | null |
2016-07-18 16:58:08 +08:00
| value | core state of mention | EditorState | null |
2017-01-22 19:49:08 +08:00
| placeholder | placeholder of input | string | null |
2016-11-02 15:04:42 +08:00
| getSuggestionContainer | rendered to the root of the menu. Default rendered to the body dom. If gets any problem of the menu while scrolling. Try to make the root the dom scrolled, and make it position relative. | Function() | () => document.body |
2016-12-09 13:03:09 +08:00
| onFocus | Callback function called when mention component get focus | function() | null |
| onBlur | Callback function called when mention component blur | function() | nul |
2016-07-04 10:31:27 +08:00
### Nav props
| Property | Description | Type | Default |
|----------|---------------|----------|--------------|
| value | value of suggestion, the value will insert into input filed while selected | string | "" |
2017-01-20 20:10:50 +08:00
| children | suggestion content | object | {} |