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
Copy file name to clipboardexpand all lines: INSTALL.md
+4-4
Original file line number
Diff line number
Diff line change
@@ -1,12 +1,12 @@
1
1
# Installation & Setup
2
2
3
-
Version >= 12 requires React Native 0.73 / Expo 50 or newer. Use version 11 if you're on older version of RN / Expo.
3
+
Version >= 12 requires React Native 0.73 / Expo 50 or newer (because of `unstable_enablePackageExports`). Use version 11 if you're on older version of RN / Expo.
4
4
5
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
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).
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
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.
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 don't need to worry about it. 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
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:
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
32
33
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
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.
Copy file name to clipboardexpand all lines: README.md
+7-6
Original file line number
Diff line number
Diff line change
@@ -109,7 +109,7 @@ See [Installation & Setup](INSTALL.md)
109
109
110
110
Is a wrapper over all the visible header buttons (those can be text-buttons, icon-button, or any custom react elements).
111
111
112
-
You should provide the `HeaderButtonComponent` prop that encapsulates how all buttons rendered in children will look. Typically, you'll want to provide a component that wraps [`HeaderButton`](#headerbutton) as seen in the example. However, you're free to use your own component (see `HeaderButton.tsx` for reference).
112
+
You should provide the `HeaderButtonComponent` prop that encapsulates how all buttons rendered in children will look. Typically, you'll want to provide a component that wraps [`HeaderButton`](#headerbutton) as seen in the example above. However, you're free to use your own component (see `HeaderButton.tsx` for reference).
113
113
114
114
In particular, it allows setting `IconComponent`, `size` and `color` in one place so that you don't need to repeat it for each icon-button - but you can override those for each `Item` if you like.
115
115
@@ -140,9 +140,9 @@ Renders text, or icon inside a [PlatformPressable](https://reactnavigation.org/d
140
140
`Item` also accepts other props that you'll typically not need to pass because `HeaderButtonComponent` already knows them (eg. `iconSize`) or because they are pulled from the React Navigation's theme object (`color`).
141
141
142
142
| additional props and type | description | note |
| IconComponent?: ComponentType | component to use for the icons, for example from `react-native-vector-icons`||
145
-
| iconSize?: number |iconSize ||
145
+
| iconSize?: number |icon size||
146
146
| color?: string | color of icons and buttons ||
147
147
| renderButton?: (params: VisibleButtonProps) => ReactNode | renders the body of the button (text or icon), defaults to `defaultRenderVisibleButton`||
148
148
@@ -151,14 +151,16 @@ Renders text, or icon inside a [PlatformPressable](https://reactnavigation.org/d
151
151
Defines the behavior for overflow button (if there is one). You can render `OverflowMenu` only by itself too, you do not need to wrap it in `HeaderButtons`.
152
152
The most important prop is `onPress` which defines what kind of overflow menu we should show.
153
153
154
+
If `OverflowMenu` contains no valid child elements, nothing will be rendered at all. (No `OverflowIcon`, no wrapper.)
155
+
154
156
The package exports common handlers you can use, but you can provide your own too (via the `onPress` prop):
|`defaultOnOverflowMenuPress`| The default. Uses `overflowMenuPressHandlerActionSheet` on iOS, and `overflowMenuPressHandlerDropdownMenu` otherwise. |
158
161
|`overflowMenuPressHandlerActionSheet`| This is iOS-only: it displays overflow items in an `ActionSheetIOS`|
159
162
|`overflowMenuPressHandlerPopupMenu`| This is Android-only: it displays overflow items using `UIManager.showPopupMenu`|
160
163
|`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. |
161
-
|`defaultOnOverflowMenuPress`| The default. Uses `overflowMenuPressHandlerActionSheet` on iOS, and `overflowMenuPressHandlerDropdownMenu` otherwise. |
162
164
163
165
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.
164
166
@@ -177,7 +179,7 @@ You can also use the [react-native-menu](https://github.com/react-native-menu/me
177
179
| other props | props passed to the nested `PlatformPressable`| pass eg. `pressColor` to control ripple color on Android |
178
180
179
181
> [!NOTE]
180
-
> There are important limitations on what can be passed as children to `OverflowMenu`. Please read below:
182
+
> There are important limitations on what can be passed as children to `OverflowMenu`:
181
183
182
184
Children passed to `OverflowMenu` should be
183
185
@@ -191,7 +193,6 @@ This limitation may look weird, but it should not really bother you in any way:
191
193
The limitation exists because we need to be able to transform declarative React elements into imperative calls (`ActionSheetIOS.showActionSheetWithOptions` / `UIManager.showPopupMenu`).
192
194
If this is a problem for you for some reason, please raise an issue, and we'll see what can be done about it.
193
195
194
-
If `OverflowMenu` contains no valid child elements, nothing will be rendered at all. (No `OverflowIcon`, no wrapper.)
0 commit comments