Search code examples
typescriptreact-reduxnext.jsnext-i18next

Exporting more than 1 default in Next _app.tsx


I came to this tricky situation, where I need to "export 2 defaults in my Next _app file (using typescript).

I started to export it for Redux, which I am using in my app

export default wrapper.withRedux(MyApp);

But now I need to translate my app with using next-i18next, where I am importing appWithTranslation and I also need to export it

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

Is it possible to have 2 export defaults somehow ?


Solution

  • It's impossible, but you can do either wrapper.withRedux(appWithTranslation(MyAppp)) or appWithTranslation(wrapper.withRedux(MyApp)) (not sure which order you need), so you will get one default export both - with redux and with translation.