Relay: Q: Passing props through RootContainer?

Created on 31 Aug 2015  路  3Comments  路  Source: facebook/relay

Any reason RootContainer is opaque when it comes to props? I'm trying to configure react-native's Navigator component to work with relay. I've gotten it to successfully work, but any components rendered into RootContainer do not have access to the navigator prop.

Navigator.renderScene

import {RootContainer} from 'react-relay';

export default function routeMapper(route, navigator) {
  var props = {
    Component: route.component,
    route: route,
    navigator: navigator
  };

  return (
    <RootContainer {...props} />
  );
}

Example route

const route = {
  name: 'root',
  component: RootController,
  params: {},
  queries: {
    viewer: (Component) => Relay.QL`
      query {
        viewer {
          ${Component.getFragment('viewer')},
        }
      }
    `
  }
};

Most helpful comment

@amccloud This is intentional - Relay.RootContainer does not pass through props. However, you can customize the props passed to the component via the renderFetched() prop. In this example, you might do:

<RootContainer
  renderFetched={data => 
    <Component {...data} navigator={navigator} />
  } />

All 3 comments

@amccloud This is intentional - Relay.RootContainer does not pass through props. However, you can customize the props passed to the component via the renderFetched() prop. In this example, you might do:

<RootContainer
  renderFetched={data => 
    <Component {...data} navigator={navigator} />
  } />

I see, thanks!

<RootContainer
  renderFetched={data => 
    <Component {...data} passedProps={this.props} />
} />

worked for me to pass between scenes using react-native-router-flux

Was this page helpful?
0 / 5 - 0 ratings

Related issues

leebyron picture leebyron  路  3Comments

xuorig picture xuorig  路  4Comments

sibelius picture sibelius  路  3Comments

scotmatson picture scotmatson  路  3Comments

rayronvictor picture rayronvictor  路  3Comments