react-navigation / react-navigation

Routing and navigation for your React Native apps
https://reactnavigation.org
23.57k stars 5.03k forks source link

Cannot change tabs with material top tab navi on android #11688

Closed ScopeSV closed 12 months ago

ScopeSV commented 12 months ago

Current behavior

When switching tabs on Android, I get the error:

Cannot read property 'setPage' of undefined

This comes from PagerView.tsx#107:62 This happened after updating to expo 49, and only happens on Android. iOS works fine.

Ive tried removed all code and only running the minimal:

export const Navigator = () => {
    return (
        <Tab.Navigator>
            <Tab.Screen
                name="test1"
                component={TestComponent}
                options={{
                    title: 'Test1',
                }}
            />
            <Tab.Screen
                name="test2"
                component={TestComponent2}
                options={{
                    title: 'Test2',
                }}
            />
        </Tab.Navigator>
    )
}

const TestComponent = () => {
    return <Text>Hey from component 1</Text>
}

const TestComponent2 = () => {
    return <Text>Hey from component 2</Text>
}

Ive tried to run a snack, and the snack works as expected with expo v49, so it's kind of hard to create a reproducible example. What may cause the setPage to be undefined?

Ive tried upgrading all react navigation packages to the latest version, and also the dependencies (ref docs). I've also tried using the same package versions as the snack from the documentation is using.

Skjermbilde 2023-11-07 kl  13 39 49

Expected behavior

To change tabs correctly

Reproduction

not-possible

Platform

Packages

Environment

package version
@react-navigation/native 6.1.9
@react-navigation/bottom-tabs 6.5.11
@react-navigation/drawer 6.6.6
@react-navigation/material-top-tabs 6.6.5
@react-navigation/stack 6.3.20
@react-navigation/native-stack 6.9.17
react-native-safe-area-context 4.7.4
react-native-screens 3.27.0
react-native-tab-view 3.5.2
react-native-pager-view 6.2.2
react-native 0.72.3
expo 49.0.0
npm or yarn yarn
github-actions[bot] commented 12 months ago

Hey @ScopeSV! Thanks for opening the issue. It seems that the issue doesn't contain a link to a repro.

The best way to get attention to your issue is to provide an easy way for a developer to reproduce the issue.

You can provide a repro using any of the following:

ScopeSV commented 12 months ago

I just want to repeat that I cannot create a reproducible example, as the very basic code is working in a slack with the same package versions, but not in the app.

ScopeSV commented 12 months ago

The tab navigation is inside a stack navigation. I am trying to create an example, but the stack navigation example won't run on v49

ScopeSV commented 12 months ago

Seems like a dependency issue. I created a new toy app and installed react navigation with nested stacks. Used the same versions, in the real app and its up and running again.

github-actions[bot] commented 12 months ago

Hey! This issue is closed and isn't watched by the core team. You are welcome to discuss the issue with others in this thread, but if you think this issue is still valid and needs to be tracked, please open a new issue with a repro.