I am trying to navigate to RouteD using CommonActions.reset in React Navigation, but the navigation works inconsistently. Sometimes it successfully navigates, but most of the time, it fails.
navigation.dispatch(
CommonActions.reset({
index: 0,
routes: [
{
name: 'RouteA',
state: {
index: 0,
routes: [
{
name: 'RouteB',
state: {
index: 3,
routes: [
{ name: 'RouteC1' }, // This route is conditional
{ name: 'RouteC2' },
{ name: 'RouteC3' },
{
name: 'RouteD',
params: {
data: []
}
},
{ name: 'RouteE' }
]
}
}
]
}
}
]
})
);