You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Version >= 12 requires React Native 0.73 / Expo 50 or newer. Use version 11 if you're on older version of RN / Expo.
4
+
5
+
Version >= 11 requires React Native 0.71 / Expo 48 or newer. Use version 10 if you're on older version of RN / Expo.
6
+
7
+
0. In your `tsconfig.json`, make sure you have [`"moduleResolution": "nodenext"`](https://www.typescriptlang.org/tsconfig#moduleResolution) set. This is required for TS to see the typings exported via [package.json `exports`](https://reactnative.dev/blog/2023/06/21/package-exports-support).
8
+
9
+
1. add [`unstable_enablePackageExports`](https://metrobundler.dev/docs/configuration/#unstable_enablepackageexports-experimental)) to your metro config (in `metro.config.js`). This field will default to `true` in a future version of RN so you can remove it and not worry about it later. This allows us to do some bundle size savings.
3. Wrap your root component in a `HeaderButtons` Provider and pass the `stackType` prop (`'native' | 'js'`), as seen in [example's App.tsx](https://github.com/vonovak/react-navigation-header-buttons/blob/master/example/src/App.tsx).
30
+
31
+
There are 3 providers to choose from - you'll get an actionable warning if you don't use the right one. They are:
32
+
33
+
-`HeaderButtonsProvider` - the recommended one, which assumes you will use `overflowMenuPressHandlerDropdownMenu` on Android but not iOS (because that's the default behavior that the library ships with). Internally, this translates to `HeaderButtonsProviderDropdownMenu` on Android and `HeaderButtonsProviderPlain` on iOS.
34
+
-`HeaderButtonsProviderPlain` - use it if you're not planning to use `overflowMenuPressHandlerDropdownMenu` at all. It will shave a few kB off your bundle and Hermes won't have to parse some code that would not run in the end.
35
+
-`HeaderButtonsProviderDropdownMenu` - use it if you're planning to use `overflowMenuPressHandlerDropdownMenu` on all platforms.
36
+
37
+
Importing: `import { your_chosen_provider } from 'react-navigation-header-buttons/your_chosen_provider'`.
38
+
39
+
> [!IMPORTANT]
40
+
> The Provider must be placed as a descendant of `NavigationContainer`, otherwise this library will not receive the correct theme from React Navigation.
Copy file name to clipboardexpand all lines: README.md
+7-29
Original file line number
Diff line number
Diff line change
@@ -6,24 +6,22 @@ This package will help you render buttons in the navigation bar and handle the s
6
6
7
7
✅ Works great with icons from `@expo/vector-icons` / `react-native-vector-icons` or any other icon library
8
8
9
-
✅ Supports both [JS](https://reactnavigation.org/docs/stack-navigator) and [native](https://reactnavigation.org/docs/native-stack-navigator/) stack
9
+
✅ Supports Expo Router, and both [JS](https://reactnavigation.org/docs/stack-navigator) and [native](https://reactnavigation.org/docs/native-stack-navigator/) stack
10
10
11
11
✅ Beautiful overflow menus for items that don't fit into the navbar
12
12
13
13
✅ [Recipes](#recipes) and examples included
14
14
15
15
✅ Written in TS
16
16
17
-
✅ Test suite for easy maintenance
18
-
17
+
✅ Test suite included (mostly good only for the maintainer, but hey, not bad to know it's there)
19
18
20
19
<!--
21
20
#### Library status
22
21
23
22
Mature: the library is stable and feature-complete. It won't be updated often not because it's abandoned, but because it doesn't need to be.
24
23
-->
25
24
26
-
27
25
#### Demo App
28
26
29
27
Contains many examples in the [example folder](https://github.com/vonovak/react-navigation-header-buttons/tree/master/example/src/screens). I highly recommend you check it out to get a better idea of the api.
@@ -75,8 +73,6 @@ export function UsageWithIcons({ navigation }) {
75
73
React.useLayoutEffect(() => {
76
74
navigation.setOptions({
77
75
title: 'Demo',
78
-
// in your app, you can extract the arrow function into a separate component
@@ -103,24 +99,9 @@ export function UsageWithIcons({ navigation }) {
103
99
}
104
100
```
105
101
106
-
## Setup
107
-
108
-
Version >= 11 requires React Native 0.71 / Expo 48 or newer. Use version 10 if you're on older version of RN / Expo.
109
-
110
-
1.`yarn add react-navigation-header-buttons`
111
-
112
-
2. Wrap your root component in a `HeaderButtons` Provider and pass the `stackType` prop (`'native' | 'js'`), as seen in [example's App.tsx](https://github.com/vonovak/react-navigation-header-buttons/blob/master/example/src/App.tsx).
113
-
114
-
There are 3 providers to choose from - but don't worry about it now, you'll get an actionable warning if you don't do it right:
115
-
116
-
-`HeaderButtonsProvider` - the default, which assumes you will use `overflowMenuPressHandlerDropdownMenu` on Android but not iOS (because that's the default behavior that the library ships with).
117
-
-`HeaderButtonsProviderPlain` - use it if you're not planning to use `overflowMenuPressHandlerDropdownMenu`. It will shave a few kB off your bundle and Hermes won't have to parse the code that would not run in the end.
118
-
-`HeaderButtonsProviderDropdownMenu` - use it if you're planning to use `overflowMenuPressHandlerDropdownMenu` on all platforms.
119
-
120
-
Importing: `import { your_chosen_provider } from 'react-navigation-header-buttons/your_chosen_provider'`.
102
+
## Installation & Setup
121
103
122
-
> [!IMPORTANT]
123
-
> The Provider must be placed as a descendant of `NavigationContainer`, otherwise this library will not receive the correct theme from React Navigation.
104
+
See [Installation & Setup](INSTALL.md)
124
105
125
106
## Usage
126
107
@@ -173,7 +154,7 @@ The most important prop is `onPress` which defines what kind of overflow menu we
173
154
The package exports common handlers you can use, but you can provide your own too (via the `onPress` prop):
|`overflowMenuPressHandlerActionSheet`| This is iOS-only: it displays overflow items in an `ActionSheetIOS`|
178
159
|`overflowMenuPressHandlerPopupMenu`| This is Android-only: it displays overflow items using `UIManager.showPopupMenu`|
179
160
|`overflowMenuPressHandlerDropdownMenu`| Can be used on iOS, Android and Web. Displays overflow items in a material popup adapted from [react-native-paper](https://callstack.github.io/react-native-paper/docs/components/Menu), credit for an amazing job goes to them. This `Menu` is bundled in this library (no dependency on `react-native-paper`) but only `require`d if you actually use it. |
@@ -184,7 +165,7 @@ You can also use the [react-native-menu](https://github.com/react-native-menu/me
| OverflowIcon: ReactElement \| ComponentType | React element or component for the overflow icon | if you provide a component, it will receive `color` prop as seen in example above |
189
170
| style?: ViewStyle | optional styles for overflow button | there are some default styles set, as seen in `OverflowButton.tsx`|
190
171
| onPress?: (OnOverflowMenuPressParams) => any | function that is called when overflow menu is pressed. | This will override the default handler. Note the default handler offers (limited) customization. See more in "Recipes". |
@@ -195,11 +176,8 @@ You can also use the [react-native-menu](https://github.com/react-native-menu/me
195
176
| preset?: 'tabHeader' \| 'stackHeader' || see [props of headerbuttons](#headerbuttons)|
196
177
| other props | props passed to the nested `PlatformPressable`| pass eg. `pressColor` to control ripple color on Android |
197
178
198
-
199
-
200
179
> [!NOTE]
201
180
> There are important limitations on what can be passed as children to `OverflowMenu`. Please read below:
202
-
>
203
181
204
182
Children passed to `OverflowMenu` should be
205
183
@@ -303,7 +281,7 @@ The default handler for overflow menu on iOS is `overflowMenuPressHandlerActionS
303
281
304
282
One of the usual things you may want to do is override the cancel button label on iOS - see [example](example/src/screens/UsageWithOverflow.tsx).
305
283
306
-
You can also use the [react-native-menu](https://github.com/react-native-menu/menu) to show the overflow menu, as seen in the example app.
284
+
You can also use the [react-native-menu](https://github.com/react-native-menu/menu)(or similar) to show the overflow menu, as seen in the example app.
The reason this is called "index" is that (it seems) the transform step of metro bundler looks for the sources and if I rename this, resolution of 'react-navigation-header-buttons/HeaderButtonsProvider' fails in the example project.
0 commit comments