Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

router.push('/') error when index page is nested inside (tabs) #445

Open
SophieJung7 opened this issue Mar 30, 2023 · 1 comment
Open

router.push('/') error when index page is nested inside (tabs) #445

SophieJung7 opened this issue Mar 30, 2023 · 1 comment

Comments

@SophieJung7
Copy link

SophieJung7 commented Mar 30, 2023

Summary

image
My folder structure is like this but when I try to do router.push('/'), there is an error as below. This might be related to conflicts between react-native and expo-router. I guess it should be resolved if it is an error. And if not an error, if I did something wrong, please refer to my code.

image

Minimal reproducible example

function RootLayoutNav() {
  return (
              <Stack>
                <Stack.Screen
                  name="(tabs)"
                  options={{
                    headerShown: false,
                  }}
                />
                <Stack.Screen name="(auth)" options={{headerShown: false}} />
              </Stack>
  );
}
export default function TabLayout() {
  return (
    <Tabs
      screenOptions={{
        tabBarActiveTintColor: 'blue',
        headerTitle: () => null,
        headerRight: () => (
          <HeaderRight power={userInfo?.power || 0} allyAmount={0} />
        ),
      }}
      initialRouteName="index">
      <Tabs.Screen
        name="index"
        options={{
          title: 'GAMES',
          tabBarIcon: ({color}) => <TabBarIcon name="code" color={color} />,
          headerLeft: () => <LogoHeader />,
        }}
      />
      <Tabs.Screen
        name="wall"
        options={{
          title: 'WALL',
          tabBarIcon: ({color}) => <TabBarIcon name="code" color={color} />,
          headerLeft: () => (
            <Pressable
              onPress={() => setIsNewsFilterVisible((oldState) => !oldState)}>
              <View style={[insets.headerLeftPadding, styles.headerLeft]}>
                <Image
                  source={require('../../src/assets/images/icons/filter.png')}
                  style={styles.filterIcon}
                />
                <Image
                  source={require('../../src/assets/images/icons/airdrop.png')}
                  style={styles.airdropIcon}
                />
              </View>
            </Pressable>
          ),
        }}
      />
      <Tabs.Screen
        name="badges"
        options={{
          title: 'BADGES',
          tabBarIcon: ({color}) => <TabBarIcon name="code" color={color} />,
        }}
      />
      <Tabs.Screen
        name="profile"
        options={{
          title: 'PROFILE',
          tabBarIcon: ({color}) => <TabBarIcon name="code" color={color} />,
        }}
      />
    </Tabs>
  );
}
@iamMAHAM
Copy link

iamMAHAM commented Mar 30, 2023

use router.push('/(tabs)') to match initial route (default to index) inside (tabs) group or router.push('/(tabs/index)') if you want to access index file inside (tabs) group

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants