react-navigation-underscore
v0.0.3
Published
A HOC to map all of your _ methods so they aren't so ugly to use with React Navigation.
Downloads
11
Maintainers
Readme
react-navigation-underscore
A HOC to map all of your _ methods so they aren't so ugly to use with React Navigation.
Install
$ npm install --save react-navigation-underscore
Usage
Will take any _ method that is on the component and make it available within the navigation parameters.
This will not include any methods that start with '_react'
import withUnderscore from "react-navigation-underscore";
class WrapMe extends React.Component {
_setSomething = () => this.setState({ something: true });
static navigationOptions = ({ navigation }) => ({
headerRight: (
<Button
onPress={(navigation.state.params || {})._setSomething}
/>
),
});
}
export default withUnderscore(WrapMe)
Parameters
component
Component React Navigation aware component
Returns Component
License
MIT © James Armstead