React-native-router-flux: How can I trigger 'onRight' in scene and update its componet's state

Created on 27 Jul 2016  路  7Comments  路  Source: aksonov/react-native-router-flux

Version

Tell us which versions you are using:

  • react-native-router-flux v3.26.13
  • react-native v0.26.3
question

Most helpful comment

@aksonov What do you mean by "But for most cases you may use navigationState instead of component's state with RNRF", and how does it solve @jingpeng challenge?

Right now I'm using redux for my app state, and when I need to show a dialog when pressing a button in the NavBar I have to update the app state, and then in componentWillReceiveProps check if I should show the dialog or not. Is there any smarter way of doing this, by using navigationState (or any smarter way in general?). Thanks in advance.

All 7 comments

I want to use default wrapped navbar in tag , but I find the onRight function cannot update component's state with Actions.refresh(). Besides, I don't want use event/subscribe mechanism, so how can I update component's state?

It won't be able to. You should move the state above the component as the NavBar cannot access another component's state.

If you want to use refresh, you can access it via this.props but I highly suggest a Flux implementation.

Yes, it seems we can only use refresh to update the props and use componentWillReceiveProps to update state

@jingpeng Maybe I've misunderstood something, but why you can't call refresh from onRight?

Oh, got it, you are talking about internal state of component... But for most cases you may use navigationState instead of component's state with RNRF...

Because I met a case that when clicking right button in NavBar, the internal component need to pop up a modal dialog, so I need to use 'refresh' method. @aksonov thanks for your explanation

@aksonov What do you mean by "But for most cases you may use navigationState instead of component's state with RNRF", and how does it solve @jingpeng challenge?

Right now I'm using redux for my app state, and when I need to show a dialog when pressing a button in the NavBar I have to update the app state, and then in componentWillReceiveProps check if I should show the dialog or not. Is there any smarter way of doing this, by using navigationState (or any smarter way in general?). Thanks in advance.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

llgoer picture llgoer  路  3Comments

YouYII picture YouYII  路  3Comments

wootwoot1234 picture wootwoot1234  路  3Comments

rafaelcorreiapoli picture rafaelcorreiapoli  路  3Comments

jgibbons picture jgibbons  路  3Comments