`index` option in navigation.reset does nothing

10
closed
Maker-Mark
Maker-Mark
Posted 3 months ago

`index` option in navigation.reset does nothing #10056

Current behavior

Calling navigation.reset with index 0 or 1 results in the same behavior. The stack always just focuses on the "top" screen, the one at the last index, here index 1 (when zero indexing for this array). I cant find any documentation on what the index actually does, except for in CommonActions (https://reactnavigation.org/docs/navigation-actions/#reset) where the index sets the focusing screen in the stack, but that's not what I'm seeing here.

  navigation.reset({
            index: 0,
            routes: [
               {
                name: 'Profile',
              },
              {
                name: 'Settings',
              }, 
            ],
          })

Expected behavior

The index param set's what screen is focused. Ie index: 1 would

Reproduction

https://snack.expo.dev/@markclair/navigation-reset-does-not-effect-focused-screen

Platform

  • Android
  • iOS
  • Web
  • Windows
  • MacOS

Packages

Environment

package version
@react-navigation/native 6.0.6
@react-navigation/stack 6.0.11
@react-navigation/native-stack 6.0.0
@react-navigation/bottom-tabs NA
@react-navigation/drawer NA
@react-navigation/material-bottom-tabs NA
@react-navigation/material-top-tabs NA
npm or yarn yarn
Next