Currently the StackNavigator's RESET functionality is half-baked. The various problems are highlighted in this older issue:
https://github.com/react-community/react-navigation/issues/351#issuecomment-303285227
I think I've come up with the simplest solution that solves the most use-cases:
StackNavigator RESET Behavior ProposalRESET
action replaces "in place" with no animationaction.direction
key lets you choose which way to animate (regardless of whether there are more or less routes on the stack than before). Possible values are: forward
or back
, and a third auto
option, whose direction will automatically be determined based on whether more or less routes were added than existed before.action.quiet === true
. By default it's falsy. But if it's set to true
, then all other indexes in your router tree state stay the same :). And the user sees nothing unless he happens to be looking at the reset StackNavigator (i.e. because all other indexes in the state happened to stay the same). Also note: the quiet
option would be useful in other actions as well, not just RESET--you should be able to target nested routers and update them with any action, and not have to take the user there in the UI. 💯Overall, this solves all problems regarding developer-control of whether the stack is replaced in place without animation vs having animation when it makes sense for the user. In addition, being able to choose direction is important because it's not always the case that if you have less routes you want a back transition. That's the developer's business, not the user's. There may be a perfectly good reason for this. That said auto
is a must since when you want the reset animated, most of the time the difference in routes gets it right (and since having to dig into current state to make the comparison is a waste of developer energy). Lastly, as far as the 2 new keys introduced--perhaps for consistency they can simply be specialized keys on the params
object.
ppong, elliottjro, augustoabreu, briankereszturi, nicgutierrez and 163 moreluco, gedeagas, Rinyeo, faustoct1, ErickMaeda and 2 moreqrobin, cccRaim, CarringtonCreative, jayprado, m1st1ck and 14 moreluco, gedeagas, peter-mach, Rinyeo, faustoct1 and 5 more
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4