Invariant Violation: withNavigation can only be used on a view hierarchy of a navigator

I use a BottomTabNavigator and a StackNavigator from react-navigation for my app.
Recently I had to update the version of react navigation from v4 to v6 and thus change the way of implementing my navigation Stack and BottomTab to match v6 implementation.

Of course it caused some errors. I’m stuck on this one :

ERROR  Invariant Violation: withNavigation can only be used on a view hierarchy of a navigator.
The wrapped component is unable to get access to navigation from props or context.

I don’t remember using ‘withNavigation’ anywhere in my app that’s why I can’t figure the issue out cause I don’t know where to search…

To me, the issue come from StackNavigator because my BottomTabNavigator used to work well before updating my StackNavigator from v4 to v6

Navigation.js

    import React, { useState } from 'react';
    import { createAppContainer } from 'react-navigation';
    import { createStackNavigator } from '@react-navigation/stack';
    import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
    
    import ALLMYSCREENS from '../Components/';
    
    const Tab = createBottomTabNavigator();
    
    function bottomNavigator() {
        const [isTabBarVisible, setTabBarVisible] = useState(true);
    
        return (
            <Tab.Navigator
                key={isTabBarVisible}
                screenOptions={({ route, navigation }) => ({
                    tabBarIcon: ({ focused }) => {
                        let iconName;
                        let activeIcon = require('../Images/V2/menu/active.png');
    
                        if (route.name === 'Home') {
                            iconName = require('../Images/V2/menu/home.png');
                        } else if (route.name === 'History') {
                            iconName = require('../Images/V2/menu/history.png');
                        } else if (route.name === 'StartScan') {
                            iconName = require('../Images/V2/menu/camera-button.png');
                        } else if (route.name === 'DailyReport') {
                            iconName = require('../Images/V2/menu/diary.png');
                        } else if (route.name === 'ProfileHome') {
                            iconName = require('../Images/V2/menu/profile.png');
                        }
    
                        if (route.name === 'StartScan') {
                            return (
                                <TouchableOpacity onPress={() => navigation.navigate('StartScan')}>
                                    <Block style={styles.cameraButton}>
                                        <Image source={iconName} style={styles.cameraImage} />
                                    </Block>
                                </TouchableOpacity>
                            );
                        }
    
                        return (
                            <Block>
                                <Image source={iconName} style={styles.image} />
                                {focused && <Image source={activeIcon} style={styles.active} />}
                            </Block>
                        );
                    },
                    tabBarShowLabel: false,
                    tabBarStyle: isTabBarVisible ? styles.bottomNavigator : { display: 'none' },
                })}
            >
                <Tab.Screen name="Home" component={Home}
                    options={{ headerShown: false }} listeners={{ focus: () => setTabBarVisible(true) }}
                />
                <Tab.Screen name="History" component={History}
                    options={{ headerShown: false }} listeners={{ focus: () => setTabBarVisible(true) }}
                />
                <Tab.Screen name="StartScan" component={StartScan}
                    options={{ headerShown: false }} listeners={{ focus: () => setTabBarVisible(false) }}
                />
                <Tab.Screen name="DailyReport" component={DailyReport}
                    options={{ headerShown: false }} listeners={{ focus: () => setTabBarVisible(true) }}
                />
                <Tab.Screen name="ProfileHome" component={ProfileHome}
                    options={{ headerShown: false }} listeners={{ focus: () => setTabBarVisible(true) }}
                />
            </Tab.Navigator>
        );
    }

const Stack = createStackNavigator();

function StackNavigator() {
    return (
        <Stack.Navigator>
            <Stack.Screen name="Main" component={bottomNavigator}
                options={{
                    title: 'Main2',
                    headerShown: false
                }}
            />
            <Stack.Screen name="Home" component={Home}
                options={{
                    title: 'Home',
                    headerShown: false
                }}
            />
        ..MORE SCREENS
        </Stack.Navigator>
    );
}

export default (StackNavigator);

App.tsx

import React from 'react';

import StackNavigator from './Navigation/Navigation';
import { NavigationContainer } from '@react-navigation/native';
import { PersistGate } from 'redux-persist/es/integration/react';
import { Provider } from 'react-redux';
import Store from './Store/configureStore';
import { persistStore } from 'redux-persist';
import 'react-native-gesture-handler';
import Toast from 'react-native-toast-message';

// Note: import explicitly to use the types shipped with jest.
import { it } from '@jest/globals';

export default class App extends React.Component {
    constructor(props: any) {
        super(props);
    }
    render() {
        return (
            <Provider store={Store}>
                <PersistGate persistor={persistStore(Store)}>
                    <NavigationContainer>
                        <StackNavigator />
                    </NavigationContainer>
                </PersistGate>
                <Toast />
            </Provider>
        );
    }
}

I would appreciate some help!

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật