我将该next-i18next
模块用于多语言应用程序。我不明白为什么会出现以下错误,因为我已经按照文档中显示的方式声明了命名空间。
错误信息:
You have not declared a namespacesRequired array on your page-level component: Home.
This will cause all namespaces to be sent down to the client, possibly negatively impacting the performance of your app.
For more info, see: https://github.com/isaachinman/next-i18next#4-declaring-namespace-dependencies
索引.ts
import Head from 'next/head'
import styles from '../styles/Home.module.css'
import { withTranslation } from '../i18n'
import { useTranslation } from 'react-i18next';
// import NextI18NextInstance from '../i18n';
function Home({ coursesData }) {
const { t, i18n } = useTranslation(['common', 'cars']);
return (
<>
<h1>{t('common:indexHeader')}</h1>
<h2>{t('cars:title')}</h2>
</>
)
}
// All works with this code, but I plan to use getServerSideProps()
// Home.getInitialProps = async () => {
// return {
// namespacesRequired: ['common', 'courses']
// }
// }
export default Home
我该如何解决这个问题?