问题
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