Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Passing props to every scene #2345

Closed
vhoen opened this issue Sep 6, 2017 · 3 comments
Closed

Passing props to every scene #2345

vhoen opened this issue Sep 6, 2017 · 3 comments

Comments

@vhoen
Copy link

vhoen commented Sep 6, 2017

Version

Tell us which versions you are using:

  • react-native-router-flux v4.0.0-beta.21 (v3 is not supported)
  • react-native v0.47.0

I am trying to migrate to react-native-router-flux v4

We used to pass a few props to the "<app />" component and theses props where passed to each Scene of our app :

import scenes from '../scenes/scenes';

class App extends Component {
  render() {
    return (
      <Router
        {...this.props}
        scenes={scenes}
      />
    );
  }
}

function mapStateToProps(state, ownProps) {
  return {
    global: state.global,
    userData: state.userData,
    ...ownProps,
  };
}

function mapDispatchToProps(dispatch) {
  return bindActionCreators({
    ...globalActions,
    ...completeActions,
  }, dispatch);
}

export default connect(mapStateToProps, mapDispatchToProps)(App);

Here is how the scenes are declared :

const scenes = Actions.create(
  <Modal>
    <Scene
      key="pageSplash"
      component={SplashViewContainer}
      title="Loading"
      initial
      hideNavBar
    />
    <Scene
      key="pageAccount"
      component={AccountUserView}
      titleKey="account"
      type={ActionConst.RESET}
    />
  </Modal>

As far as I can see, props are correctly set in but never reach any Scene. It worked with react-native-router-flux v3, but not anymore.

Is there something I am missing ?

@weiqingtangx
Copy link

<Scene {...this.props} key="login" component={RNHighScores} title="Login" initial={true} />
I think you should pass props to the scene.

@vhoen
Copy link
Author

vhoen commented Sep 8, 2017

I didn't have to that in v3 and I was hoping wouldn't have to do this. My scenes are imported from several files and there are a bunch of scenes so it would be quite time consuming.

Thanks for your answer.

@aksonov
Copy link
Owner

aksonov commented Sep 10, 2017

You have to move scenes into Router for this, or pass params as second argument for Actions.create

@aksonov aksonov closed this as completed Sep 10, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants