0.0.3 • Published 6 years ago

react-navigation-underscore v0.0.3

Weekly downloads
4
License
MIT
Repository
github
Last release
6 years ago

react-navigation-underscore

Generated with nod NPM version Build Status Coverage Status

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