在 Next _app.tsx 中导出超过 1 个默认值

Exporting more than 1 default in Next _app.tsx

我遇到了这个棘手的情况,我需要“在我的 Next _app 文件中导出 2 个默认值(使用打字稿)。

我开始为我在我的应用程序中使用的 Redux 导出它

export default wrapper.withRedux(MyApp);

但现在我需要使用 next-i18next 翻译我的应用程序,我在其中导入 appWithTranslation 并且还需要导出它

import { appWithTranslation } from 'next-i18next';
export default appWithTranslation(MyApp);

是否可以通过某种方式设置 2 个导出默认值?

这是不可能的,但是您可以执行 wrapper.withRedux(appWithTranslation(MyAppp))appWithTranslation(wrapper.withRedux(MyApp))(不确定您需要哪个顺序),因此您将获得一个默认导出 - 使用 redux 和使用翻译。