diff --git a/text/0000-less-pushy-navigate.md b/text/0000-less-pushy-navigate.md new file mode 100644 index 0000000..68988d1 --- /dev/null +++ b/text/0000-less-pushy-navigate.md @@ -0,0 +1,116 @@ +- Start Date: 2018-02-23 +- RFC PR: (leave this empty) +- React Navigation Issue: (leave this empty) + +# Summary + +This RFC suggests making the `navigate` action for `StackRouter` focus the given `routeName` if it already exists in `StackRouter` state, rather than the current behavior of pushing it. If it does not exist in the state but the `StackRouter` handles the route, then it will push it. + +In other words, this proposed change is the same as how `StackRouter` behaves if you specify a `key` to the `navigate` action but without requiring that the user specify a `key` to take advantage of the behavior. If no `key` is provided, `StackRouter` assumes the user just wants to either jump to the route by the given name if it exists in state already or push it if not. + +In addition to this change, `push` and other `StackRouter` related navigation helpers will be changed from non-bubbling & specific to the deepest `StackRouter` to be global in the same way that `navigate` is -- when you push the new route it can be handled by any `StackRouter` in the state tree. The reason for this is that there is now a clear use case for why this matters. Take for example the flow of navigating from a user profile -> comment -> user profile. It is conceivable that you may visit user profile for "Jane", then in a comment visit the profile for "Bob", then in a comment visit "Jane" again. In this situation it is expected that the second time you visit "Jane" it pushes a new profile screen on top, rather than jumping back to the first one. For these situations, users should use `push`. + +# Basic example + +In the "Moving between screens" section of the documentation, we have the following example: + +``` +class DetailsScreen extends React.Component { + render() { + return ( + + Details Screen +