Skip to content

Conversation

jimmyfagan
Copy link
Contributor

Ticket

resolves #51

Changes

Removed the react property from the i18n property in next-i18next.config.json.

Context for reviewers

When running the build, prior to this change, the output would show:

warn  - Invalid next.config.js options detected: 
  - The value at .i18n has an unexpected property, react, which is not in the list of allowed properties (defaultLocale, domains, localeDetection, locales).

See more info here: https://nextjs.org/docs/messages/invalid-next-config

The problematic config looked like this:

    react: {
      // Add support for <em>.
      // See https://react.i18next.com/latest/trans-component#using-for-less-than-br-greater-than-and-other-simple-html-elements-in-translations-v-10-4-0
      transKeepBasicHtmlNodesFor: ["br", "strong", "i", "p", "em"],
    },

I'm not aware of a good reason for that setting to be set generally in the template; the link in the comment was outdated, so the anchor it tried to connect to no longer exists, but at the top of that page, it says "the truth is: in most cases you don't even need it" in reference to the Trans component the transKeepBasicHtmlNodesFor setting connects to. There may be reason for an individual application to use that setting, but I don't think the template needs to have it by default, and either way, the option was being set improperly anyway, so I opted to remove the react property altogether.

Testing

Ran npm run test and npm run dev and everything seems to work as normal. Running npm run build no longer shows the error message referenced in the issue.

@jimmyfagan jimmyfagan requested a review from aligg October 17, 2022 21:25
Copy link
Contributor

@aligg aligg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sense to me esp since the prior anchor in the docs is outdated, however might be worth @rocketnova taking a look in case they have context from why we initially added this that we may be missing!

@jimmyfagan jimmyfagan requested a review from rocketnova October 18, 2022 16:36
@jimmyfagan
Copy link
Contributor Author

Good call, will add Rocket as a reviewer!

@rocketnova no urgency on this at all, just let us know whether or not this looks okay whenever you get a minute. Thanks!

@@ -2,10 +2,5 @@ module.exports = {
i18n: {
defaultLocale: "en",
locales: ["en", "es"],
react: {
Copy link
Contributor

@sawyerh sawyerh Oct 19, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's poorly documented but it looks like the fix, while preserving the safelisting of em, is to unnest this react object outside of the i18n object:

CleanShot 2022-10-19 at 09 25 49@2x

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know you've removed your blocking review, just for the record, I'm fine with this approach too; it's one of those cases where I don't quite understand why em isn't included by default, so it's just a question of whether to go with the default because it's the default, or with something else that seems to make more sense. Since it's not likely to matter either way, I'm still thinking we stick with the default in the template. I'll leave this open for another day or so in case Rocket wants to chime in, and then I'll close this out.

Copy link
Contributor

@sawyerh sawyerh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There may be reason for an individual application to use that setting, but I don't think the template needs to have it by default, and either way, the option was being set improperly anyway, so I opted to remove the react property altogether.

Sorry, I should have read your PR description before reviewing! I'm fine with this, so removing my blocking review.

@jimmyfagan jimmyfagan merged commit 48e1d43 into main Oct 20, 2022
@jimmyfagan jimmyfagan deleted the jimmy/fixWarning branch October 20, 2022 16:45
@jimmyfagan jimmyfagan removed the request for review from rocketnova October 20, 2022 16:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Warning when running npm run build
3 participants