score:1

Accepted answer
const NavBar = ({ setLanguage }) => {
    ...
    <li className='nav-item'>
        <div className='nav-links' role='button' onClick={() => {
            setLanguage('chi');
            closeMobileMenu();
        }}>
            中文
        </div>
        /
        <div className='nav-links' role='button' onClick={() => {
            setLanguage('eng');
            closeMobileMenu();
        }}>
            Eng
        </div>
    </li>
    ...
}

score:2

...
<Route path='/' exact component={HomePage}/>
...
const HomePage = () => {
   const [lang, setLang] = useState('eng');

   return lang === 'eng' ? <EnglishHomePage/> : <ChineseHomePage/>
}

Related Query

More Query from same tag