examples
Please see `UsageWithOverflowComplex.tsx` for valid examples!
These will NOT work with `overflowMenuPressHandlerActionSheet` and `overflowMenuPressHandlerPopupMenu`:
1. WRONG! no hooks are allowed!
```js
function MyComponent({ title }) {
const [titleFromState, setTitle] = React.useState('from state hook');
return alert('fail')} />;
}
}>
;
```
2. WRONG! you can nest `HiddenItem` only once, not twice
```js
const HiddenItemWrapped = () => alert('hidden2')} />;
const HiddenItemWrappedTwice = ()=>
}>
;
```
#### `HiddenItem`
`HiddenItem` accepts:
| prop and type | description | note |
| -------------------------- | ------------------------------------------------------------------ | ---------------------------------------------------------------------- |
| title: string | title for the button, required | |
| style?: ViewStyleProp | style to apply to the touchable element that wraps the text | |
| titleStyle?: ViewStyleProp | style to apply to the text | |
| onPress: ?() => any | function to call on press | |
| testID?: string | testID to locate view in e2e tests | |
| disabled?: boolean | disabled 'item' is greyed out and `onPress` is not called on touch | |
| destructive?: boolean | flag specifying whether this item is destructive | only applies to items shown with `overflowMenuPressHandlerActionSheet` |
#### `OverflowMenuProvider`
This is a React context provider needed for `overflowMenuPressHandlerDropdownMenu` to work. If you're not using `overflowMenuPressHandlerDropdownMenu` then you don't need it.
By default, you need to wrap your root component with it.
`OverflowMenuProvider` accepts an optional `spaceAboveMenu` prop, which can be used to set the distance between the top of the screen and the top of the overflow menu.
#### `HeaderButton`
You will typically not use `HeaderButton` directly. `HeaderButton` is where all the `onPress`, `title` and Icon-related props (color, size) meet to render actual button.
See the source if you want to customize it.
### Recipes
#### Customizing the overflow menu
The default handler for overflow menu on iOS is `overflowMenuPressHandlerActionSheet`.
One of the usual things you may want to do is override the cancel button label on iOS - see [example](example/screens/UsageWithOverflow.tsx).
#### Using custom text transforms
Use the `buttonStyle` prop to set [`textTransform`](https://reactnative.dev/docs/text-style-props#texttransform) styles for button titles.
#### How to integrate in your project
This sections covers how you should use the library in your project. Please note that there are numerous [example screens](https://github.com/vonovak/react-navigation-header-buttons/tree/master/example/screens).
1 . Define one file where the styling of header buttons is taken care of.
```js
// MyHeaderButtons.js
import * as React from 'react';
import MaterialIcons from 'react-native-vector-icons/MaterialIcons';
import { HeaderButtons, HeaderButton } from 'react-navigation-header-buttons';
// define IconComponent, color, sizes and OverflowIcon in one place
const MaterialHeaderButton = (props) => (