Next.js 12.3.0 AppProps generic breaks appWithTranslation type
See original GitHub issueNext.js 12.3.0 #38867 introduces the use of a generic for AppProps type, that is incompatible with appWithTranslation
type.
To Reproduce
The following example causes a TypeScript error (TS2345):Argument of type '({ Component, pageProps }: AppProps<{ session: Session;}>) => JSX.Element' is not assignable to parameter of type 'ComponentType<AppProps>'
.
const App = ({Component, pageProps}: AppProps<{session: Session}>) => (
<SessionProvider session={pageProps.session}>
<ThemeProvider>
<Component {...pageProps} />
</ThemeProvider>
</SessionProvider>
)
export default appWithTranslation(App)
Issue Analytics
- State:
- Created a year ago
- Reactions:22
- Comments:17 (5 by maintainers)
Top Results From Across the Web
Blog - Next.js 12.3
Next.js 12.3 introduces TypeScript Auto-Install, improved Fast Refresh, stable new Image Component, and more!
Read more >next-i18next - Bountysource
Next.js 12.3.0 #38867 introduces the use of a generic for AppProps type, that is incompatible with appWithTranslation type.
Read more >How to use next-auth with per page layouts in Next.js with ...
You can add a generics type to AppPropsWithLayout , then use it in the MyApp 's props type and pass the right type...
Read more >next-i18next's Language Statistics - Codesti
Issue Title State Comments Created Date Upd...
Module not found: Can't resolve 'react‑i18next' closed 1 2022‑12‑11 2022...
Text content does not match server‑rendered HTML. closed...
Read more >Internationalize the Next.js application using next-i18next
_app.tsximport type { AppProps } from “next/app”; import “../styles/globals.css”; import { appWithTranslation } from “next-i18next”;function MyApp({ ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thanks Ebrahim, worked for me with a little tweak:
export default appWithTranslation(MyApp as FC)
a new major version will be published as soon as -> #1966