* Pops out a route from the navigation state. * Note that this moves the index to the position to where the last route in the * stack is at.
(state)
| 60 | * stack is at. |
| 61 | */ |
| 62 | pop(state) { |
| 63 | if (state.index <= 0) { |
| 64 | // [Note]: Over-popping does not throw error. Instead, it will be no-op. |
| 65 | return state; |
| 66 | } |
| 67 | const routes = state.routes.slice(0, -1); |
| 68 | return { |
| 69 | ...state, |
| 70 | index: routes.length - 1, |
| 71 | routes, |
| 72 | }; |
| 73 | }, |
| 74 | |
| 75 | /** |
| 76 | * Sets the focused route of the navigation state by index. |