-
-
Notifications
You must be signed in to change notification settings - Fork 206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
next-translate doesn't load if using styled components #366
Comments
It's rare because next-translate does nothing with the file _document.js. Is it the same with the canary version 1.0? Can you create a reproducible example? |
If in 1.0.0-canary.2 is already fixed I wouldn't worry too much because we will release it soon. Could you check it out? Useful links:In 1.0 the |
Thanks, let me take a look |
I'm actually using canary 1.0.0-canary.2 and see the problem there. |
And removing next-translate it works? It's strange because we don't touch the |
Yes, removing it fixes it. Let me try adding a reprodusable example. |
@dsauna this would be very useful! Thank you! |
@aralroca I found the really weird issues. I don't think it has anything to do with styled components. The issue is that if you use next-translate and your _app.tsx/_app.js is a class component it will fail. Easy fix to not use a class component, you can see the issue here. Not sure if a bug, but it took me a while to realize. |
Thanks @dsauna, I'll look into it then! Well seen |
Thank you for putting the hard work into this. Let me know if you need any help |
This comment has been minimized.
This comment has been minimized.
Ah sorry, I didn't see the repo https://github.com/dsauna/next-translate-styled, this works for me, thank you very much! |
It's curious because this works: import React from 'react'
import type { AppProps } from 'next/app'
import '../styles.css'
class MyApp extends React.Component<AppProps> {
render() {
const { Component, pageProps } = this.props
return <Component {...pageProps} />
}
}
export default MyApp But this no: import React from 'react'
import NextApp from 'next/app'
import '../styles.css'
class MyApp extends NextApp {
render() {
const { Component, pageProps } = this.props
return <Component {...pageProps} />
}
}
export default MyApp And the compiled code for the failing case is: +import __i18nConfig from '@next-translate-root/i18n'
+import __appWithI18n from 'next-translate/appWithI18n'
import React from 'react'
import NextApp from 'next/app'
import '../styles.css'
class MyApp extends NextApp {
render() {
const { Component, pageProps } = this.props
return <Component {...pageProps} />
}
}
-export default MyApp
+const __Page_Next_Translate__ = MyApp
+export default __appWithI18n(__Page_Next_Translate__, {
+ ...__i18nConfig,
+ isLoader: true,
+ skipInitialProps: true,
+}); Apparently looks correct, maybe the problem is inside the |
@dsauna I have finally found the root of the problem. It seems that NextApp causes Next.js to serve its modified default |
I did a prerelease 1.0.0-canary.3, now it should work 👍 |
ah! that's amazing, thanks so much |
When adding a configuration, I get an error in _document that says
Class constructor App cannot be invoked without 'new'
The text was updated successfully, but these errors were encountered: