Reputation: 880
I have an app (react native/redux/navigation experimental) that has deep flows where a user can navigate to multiple instances of the same screen (think tapping through to multiple profiles).
To avoid each new instance of the screen overwriting data on the screens before it, I’m using a lookup table approach in redux. Each time I push to a new screen, I use a uuid for the route as a key in the lookup table.
Is there a better way to handle this?
Upvotes: 2
Views: 1597
Reputation: 881
I would suggest upgrading the routing framework as React Native Experimental will no longer be supported. You could try either react native router flux or react navigation . I haven't used the latter, so how I would accomplish this in React Native router flux is by: a) utilizing different keys for the same component which you seem to be doing. b) passing the uuid
as params to that component upon navigation. E.g.
Actions[routes.currentUser]({ uuid: getUuid() })
where your routes are defined in some other file and you retrieve the uuid. As explained here
Also, it is generally best practice to separate Navigation State and Application state as explained here
Upvotes: 1