reactjs - next-18next 与最新的 nextjs 集成时出错:在没有 next-i18next 配置的情况下调用了 appWithTranslation
问题描述
我正在将今天的应用程序升级到最新的 nextjs 版本(10.0.9)。
为了移动翻译,我使用了next-i18next库及其来自 Github 的简单示例。
在 next-i18next lib 的调试器上,我发现未提供 i18n 配置时引发的此错误。
在我的应用程序配置中看起来像:
_app.js
const HeadstartApp = (props) => {
const { Component, apollo, redux, theme } = props;
const reduxRef = useRef(initRedux(redux));
const apolloRef = useRef(
getApolloClient()
);
return (
<React.Fragment>
<Head>
<title>Example</title>
<meta
name='viewport'
content='minimum-scale=1, initial-scale=1, width=device-width'
/>
</Head>
<ApolloProvider client={apolloRef.current}>
<Provider store={reduxRef.current}>
<div dir={locale === 'he' ? 'rtl' : 'ltr'}>
<ThemeProvider theme={createMuiTheme(theme)}>
{/* <AppBar position={'static'}>
<Toolbar>
<Typography>
<h1>{locale}</h1>
</Typography>
<Link href='/projects/construction/1'>
<Button>Project 1</Button>
</Link>
<Link href='/projects/digital/2'>
<Button>Project 2</Button>
</Link>
</Toolbar>
</AppBar> */}
<Layout {...props}>
<Component {...props} />
</Layout>
</ThemeProvider>
</div>
</Provider>
</ApolloProvider>
</React.Fragment>
);
};
}
export default appWithTranslation(HeadstartApp);
index.js
const HomePage = (props) => {
...code
}
export const getStaticProps = async ({ locale, defaultLocale }) => ({
props: {
...(await serverSideTranslations(locale || defaultLocale, [
'common',
'homepage',
])),
},
});
export default HomePage;
看起来我的应用程序与这里的简单示例具有相同的配置,但抛出了这个奇怪的异常。有人得到了一些东西,可以帮助解决它
解决方案
推荐阅读
- stripe-payments - 如何将资金转移到非关联的 Stripe 账户
- flutter - Flutter:以毫米为单位创建标尺
- networking - 多播场景中的接收者如何知道它应该监听哪个 IP 地址?
- wordpress - 如何在不加载页面的情况下将简单的表单提交转换为 ajax 提交,例如将产品添加到购物车功能
- angular - 如何从角度的单个函数返回订阅和承诺?
- vb.net - VB.Net:Winforms Designer:在父自定义控件中使用自定义控件中的动词
- azure - 在 Azure 中通过 Powershell 执行远程命令,无需脚本
- c# - 需要解释一下,为什么EF核心现在需要使用attach
- airflow-scheduler - 当属性'catchup = false'时了解气流执行日期
- javascript - Angular 8 防止在重复选项卡上的浏览器选项卡之间共享会话