Skip to content

Instantly share code, notes, and snippets.

Last active July 20, 2019 12:36
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
HOC for react-navigation that maps params to props
import paramsToProps from 'paramsToProps.js'
const MainNavigator = StackNavigator({
firstScreen: { screen: paramsToProps(FirstScreenComponent) },
secondScreen: { screen: paramsToProps(SecondScreenComponent) },
import React, { Component } from 'react';
export default (OriginalComponent) => {
return class ParamsToPropsWrapper extends Component {
static navigationOptions = OriginalComponent.navigationOptions;
render() {
const params = this.props.navigation.state.params;
return <OriginalComponent {...this.props} {...params} />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment