Skip to content
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

Namespace: Cannot read properties of undefined (reading 'forEach') #1913

Closed
meabed opened this issue Jul 18, 2022 · 4 comments
Closed

Namespace: Cannot read properties of undefined (reading 'forEach') #1913

meabed opened this issue Jul 18, 2022 · 4 comments

Comments

@meabed
Copy link

meabed commented Jul 18, 2022

🐛 Bug Report

Error with namespace .forEach

error - TypeError: Cannot read properties of undefined (reading 'forEach')
    at /node_modules/i18next/dist/cjs/i18next.js:1912:20
    at Array.forEach (<anonymous>)
    at Connector.queueLoad (/node_modules/i18next/dist/cjs/i18next.js:1910:17)
    at Connector.prepareLoading (/node_modules/i18next/dist/cjs/i18next.js:2048:25)
    at Connector.load (/node_modules/i18next/dist/cjs/i18next.js:2062:12)
    at I18n.loadResources (/node_modules/i18next/dist/cjs/i18next.js:2459:40)
    at setLng (/node_modules/i18next/dist/cjs/i18next.js:2585:16)
    at I18n.changeLanguage (/node_modules/i18next/dist/cjs/i18next.js:2595:9)
    at load (/node_modules/i18next/dist/cjs/i18next.js:2409:16)
    at I18n.init (/node_modules/i18next/dist/cjs/i18next.js:2413:9) {
  page: '/'

To Reproduce

A minimal reproducible example.
A codesandbox example or similar
or at least steps to reproduce the behavior:

const HttpBackend = require('i18next-http-backend/cjs');
const ChainedBackend = require('i18next-chained-backend').default;
const LocalStorageBackend = require('i18next-localstorage-backend').default;

const isProd = process.env.NODE_ENV === 'production';

module.exports = {
  backend: {
    backendOptions: [{ expirationTime: !isProd ? 0 : 30 * 60 * 1000 }, {}], // Translation cached for 30 min on production
    backends: typeof window !== 'undefined' ? [LocalStorageBackend, HttpBackend] : []
  },
  i18n: {
    defaultLocale: 'en',
    locales: ['en', 'es']
  },
  serializeConfig: false,
  use: typeof window !== 'undefined' ? [ChainedBackend] : [],
  reloadOnPrerender: !isProd
};

Expected behavior

A clear and concise description of what you expected to happen.

// Paste the expected results here

Your Environment

  • nextjs: 12.2.2
  • next-i18next: 11.2.1
  • node: 18
@adrai
Copy link
Member

adrai commented Jul 18, 2022

can you try with v11.2.2 ?

@meabed
Copy link
Author

meabed commented Jul 18, 2022

Yes, its fixed and works fine 👍

@adrai adrai closed this as completed Jul 18, 2022
@adrai
Copy link
Member

adrai commented Jul 18, 2022

//cc: @felixmosh

@felixmosh
Copy link
Contributor

felixmosh commented Jul 18, 2022

Weird, the ns prop is a new one, it was undefined before... :|
Thank you for the fast fix.

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

No branches or pull requests

3 participants