howljs / react-native-auto-route

React Native Auto Route is a file-based router for React Native CLI
https://howljs.github.io/react-native-auto-route/
MIT License
28 stars 2 forks source link

How to get name of screen #1

Closed UIT19521334 closed 6 months ago

UIT19521334 commented 6 months ago

This is my code and router name allway given = (tabs) when i change tab what shoud i do

import { useRoute } from '@react-navigation/native';

export default function Layout() {
  const route = useRoute();
  return (
    <Tabs
      initialRouteName="(drawer)" // initialRouteName is directory name or filename
      screenOptions={{
        // https://reactnavigation.org/docs/native-stack-navigator#props
        headerStyle: {
          backgroundColor: '#f4511e',
        },
        headerTintColor: '#fff',
        headerTitleStyle: {
          fontWeight: 'bold',
        },
        tabBarIcon: ({ focused, color, size }) => {
          console.log(focused);
          let iconName;
          console.log(route.name);},
      }}>
        <Tabs.Screen
                name="(drawer)" // name prop is directory name or filename
                options={{
                  tabBarBadge: 3 
                }} 
              />
        <Tabs.Screen
                name="profile/index" // name prop is directory name or filename
                options={{

                }} 
              />
    </Tabs>