React Native Router Flux: Transition and history using this same scene but with other parameters

五迷三道 提交于 2020-01-06 07:29:11

问题


I'm creating a shop app and I'm using react-native-router-flux as a router. Currently, I have just few scenes like product list, product info, basket and checkout.

But I need to create a navigation. I have JSON with whole navigation structure, where ID of category is the ID for call to API when ProductList scene calls componentDidMount().

But I don't know how to:

a) use this same scene but with additional parameters and refresh it -- I suppose that I should do something like Actions.refresh({ key: PRODUCT_LIST, params: { categoryId: 12345 } })?

b) how to handle this same scene transitions history? I mean if I'll do some Actions.refresh() how can I go back to previous categories I refreshed before?

As a state manager in the app, I'm using Redux. But I'm not using it for router (I had some issues to pair RNRF and Redux).

Or maybe you have other ideas how to handle this case?

Best regards, Marcin


回答1:


2 way for solve this problem :

1: Create two Scenes from the your special component like this :

<Scene key="one" component={Home}/>
<Scene key="two" component={Home}/>

2: And yes you can set params in your Actions.refresh({ param1: 'someData'}); And after that you have access to these in your props! like this:

console.log(this.props.param1);


来源:https://stackoverflow.com/questions/51785699/react-native-router-flux-transition-and-history-using-this-same-scene-but-with

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!