1 | # Public Methods
|
2 | To access the component's public methods, pass a ref to your typeahead then access the ref in your code:
|
3 | ```jsx
|
4 | const ref = React.createRef();
|
5 |
|
6 | <>
|
7 | <Typeahead
|
8 | ...
|
9 | ref={ref}
|
10 | />
|
11 | <button onClick={() => ref.current.clear()}>
|
12 | Clear Typeahead
|
13 | </button>
|
14 | </>
|
15 | ```
|
16 |
|
17 | Name | Description
|
18 | ---- | -----------
|
19 | `blur()` | Blurs the input.
|
20 | `clear()` | Resets the typeahead component. Clears both text and selection(s).
|
21 | `focus()` | Focuses the input.
|
22 | `getInput()` | Provides access to the component's input node.
|
23 | `hideMenu()` | Hides the menu.
|
24 | `toggleMenu()` | Shows the menu if it is currently hidden; hides the menu if it is currently shown.
|
25 |
|
26 | [Next: API](API.md)
|