You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I had to wrap the export with the nextTranslate function otherwise I'd get translatios missing errors in the console (although they were there). Wrapping it like this fixed this error..
Sentry has an OpenAI assistant which provided the following possible fix:
To fix this, we need to make sure that the 'pageProps' property is defined before trying to access it. One way to do this is by adding a nullish coalescing operator (??) to the code. We can modify the line with the error like this:
react_1.default.createElement(I18nProvider_1.default, { lang: ((_a = props.pageProps) === null || _a === void 0 ? void 0 : _a.__lang) ?? props.__lang || defaultLocale })
This will check if 'props.pageProps' is null or undefined and use the value of 'props.__lang' or 'defaultLocale' as a fallback. Ta-da! Problem solved! 🎉
What did you expect to happen?
Nothing, there were absolutely no errors before implementing Sentry.
Are you willing to submit a pull request to fix this bug?
Maybe, if the above AI suggestion is valid.
EDIT: Typos.
The text was updated successfully, but these errors were encountered:
What version of this package are you using?
next-translate
v2.6.2What operating system, Node.js, and npm version?
Node 22.2.0, npm v10.8.1
What happened?
After implementing Sentry (https://docs.sentry.io/platforms/javascript/guides/nextjs/), upon first running
npm run dev
, the following error is captured:This is happening on line 65 of
appWithI18n.js
.Thanks to Sentry, I can check for the the code causing this error:
My
next.config.js
module exports is as follows:I had to wrap the export with the
nextTranslate
function otherwise I'd get translatios missing errors in the console (although they were there). Wrapping it like this fixed this error..Sentry has an OpenAI assistant which provided the following possible fix:
To fix this, we need to make sure that the 'pageProps' property is defined before trying to access it. One way to do this is by adding a nullish coalescing operator (??) to the code. We can modify the line with the error like this:
react_1.default.createElement(I18nProvider_1.default, { lang: ((_a = props.pageProps) === null || _a === void 0 ? void 0 : _a.__lang) ?? props.__lang || defaultLocale })
This will check if 'props.pageProps' is null or undefined and use the value of 'props.__lang' or 'defaultLocale' as a fallback. Ta-da! Problem solved! 🎉
What did you expect to happen?
Nothing, there were absolutely no errors before implementing Sentry.
Are you willing to submit a pull request to fix this bug?
Maybe, if the above AI suggestion is valid.
EDIT: Typos.
The text was updated successfully, but these errors were encountered: