router icon indicating copy to clipboard operation
router copied to clipboard

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

Open SophieJung7 opened this issue 1 year ago • 1 comments

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>
  );
}

SophieJung7 avatar Mar 30 '23 04:03 SophieJung7