import React, { useEffect, useState } from 'react' import { css, cx } from '@emotion/css' import Icon from '../Icon' import { NavLink, useLocation } from 'react-router-dom' import { useAnimation, motion } from 'framer-motion' import { ease } from '@/web/utils/const' const tabs = [ { name: 'MY MUSIC', path: '/', icon: 'my', }, { name: 'DISCOVER', path: '/discover', icon: 'explore', }, { name: 'BROWSE', path: '/browse', icon: 'discovery', }, { name: 'LYRICS', path: '/lyrics', icon: 'lyrics', }, ] as const const getNameByPath = (path: string): string => { return tabs.find(tab => tab.path === path)?.name || '' } const TabName = () => { const location = useLocation() const [name, setName] = useState(getNameByPath(location.pathname)) const controls = useAnimation() useEffect(() => { const newName = getNameByPath(location.pathname) const animate = async () => { await controls.start('out') setName(newName) await controls.start('in') } if (newName !== name) animate() }, [controls, location.pathname, name]) return (