import { useState } from 'react';
import Home from '../home';
import Mine from '../user/mine';
import BottomBarContext from '@/context/bottomBarContext';
import useStore from '@/hooks/useRedux';


const BottomNavBar = () => {
    const [index, setIndex] = useState(0);
    const menu = useStore(p => p.tabMenu);
    return (
        <BottomBarContext.Provider value={{
            switchTo: setIndex,
            index
        }}  >
            {
                menu.map(p => {
                    if (p.code === "home") {
                        return (
                            <Home />
                        )
                    }
                    else if (p.code === "user_center") {
                        return <Mine />
                    }
                })
            }
        </BottomBarContext.Provider>
    )
}

export default BottomNavBar;