Skip to content

Commit 1d6ae57

Browse files
committed
docs: update README with ref usage example
1 parent cf03384 commit 1d6ae57

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

README.md

+15-1
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,20 @@ npx pod-install
4040
## Usage
4141

4242
```jsx
43-
import { MenuView } from '@react-native-menu/menu';
43+
import { MenuView, MenuComponentRef } from '@react-native-menu/menu';
4444

4545
// ...
4646

4747
const App = () => {
48+
const menuRef = useRef<MenuComponentRef>(null);
4849
return (
4950
<View style={styles.container}>
51+
<Button
52+
title="Show Menu with ref (Android only)"
53+
onPress={() => menuRef.current?.show()}
54+
/>
5055
<MenuView
56+
ref={menuRef}
5157
title="Menu Title"
5258
onPressAction={({ nativeEvent }) => {
5359
console.warn(JSON.stringify(nativeEvent));
@@ -131,6 +137,14 @@ It's also possible to obtain the `action` is a more React-ish, declarative fashi
131137
132138
### Props
133139
140+
#### `ref` (Android only)
141+
142+
Ref to the menu component.
143+
144+
| Type | Required |
145+
|------|----------|
146+
| ref | No |
147+
134148
### `title` (iOS only)
135149
136150
The title of the menu.

0 commit comments

Comments
 (0)