找不到模块“react-i18next”

5 javascript reactjs react-i18next

这是我的代码:

import React from 'react';
import { useTranslation } from 'react-i18next';

 function MyComponent() {
  const { t, i18n } = useTranslation();

  return <p>{t('my translated text')}</p>
}


export default MyComponent;
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:Cannot find module 'react-i18next'

关于如何修复它有什么想法吗?谢谢你!

Ben*_*gan 8

在你的控制台中输入npm install react-i18next

你需要安装该模块