Skip to content

Instantly share code, notes, and snippets.

@JodusNodus
Last active August 1, 2017 19:49
Show Gist options
  • Select an option

  • Save JodusNodus/bf8d76f44617ed32b0857634b8545e37 to your computer and use it in GitHub Desktop.

Select an option

Save JodusNodus/bf8d76f44617ed32b0857634b8545e37 to your computer and use it in GitHub Desktop.
Declarative logic React components
class SomeView extends Component {
static propTypes = {
showNav: PropTypes.func.isRequired,
hideNav: PropTypes.func.isRequired
}
componentDidMount(){
this.props.showNav()
BackHandler.addEventListener('hardwareBackPress', this.handleBack)
}
componentWillUnmount(){
this.props.hideNav()
BackHandler.removeEventListener('hardwareBackPress', this.handleBack)
}
handleBack = () => {}// ? Do some navigation logic ?
render = () => (
<View>
<Text>Some text</Text>
</View>
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment