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

Error with import { initReactI18next } from "react-i18next" #1797

Open
jvictor98 opened this issue Aug 26, 2024 · 6 comments
Open

Error with import { initReactI18next } from "react-i18next" #1797

jvictor98 opened this issue Aug 26, 2024 · 6 comments

Comments

@jvictor98
Copy link

jvictor98 commented Aug 26, 2024

🐛 Bug Report

Error with import { initReactI18next } from "react-i18next";
Whenever I refer (Import {Initreacti18Next} from "React-i18Next";) The following error appears "Unexpect token '?'". .The same happens if I refer to (Import {Usetranslation} from 'React-i18Next';).
I tried everything, clean cache, node, and even started another project and this mistake does not disappear, someone Can you help me?

To Reproduce

React Native

import pt from "./pt.json";
import en from "./en.json";
import i18n from 'i18next';
import { initReactI18next } from "react-i18next";


i18n.use(initReactI18next).init({
    compatibilityJSON: 'v3',
    lng: 'en',
    resources: {
        en: en,
        pt: pt
    },
    react: {
        useSuspense: false,
    },
    interpolation: {
        escapeValue: false
    }
})

export default i18n;

Expected behavior

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

// Paste the expected results here

Your Environment

  • runtime version: node v14.20.1 and 16.18.1,
  • i18next version: i.e. ^15.0.1",
  • os: Windows
  • any other relevant information:
  • using in React Native, just android, mac looks ok
    "react": "17.0.2",
    i18next": "^23.14.0"
    openjdk-11.0.14.1_1
@anniewey
Copy link

anniewey commented Aug 28, 2024

Facing same issue, getting errors at launch. Only occur in Android, iOS was fine.

error node_modules/react-i18next/dist/commonjs/context.js: Unexpected token: operator (?) in file node_modules/react-i18next/dist/commonjs/context.js at 56:36.
Error: Unexpected token: operator (?) in file node_modules/react-i18next/dist/commonjs/context.js at 56:36

Notice that nullish coalescing was introduced in v15.0.0, hence downgrading to version below it (v14.1.3) solves the issue. @jvictor98 can use v14 temp while wait for the fixes.

@adrai
Copy link
Member

adrai commented Aug 29, 2024

@VIKTORVAV99 here another one ;-)

@VIKTORVAV99
Copy link
Contributor

VIKTORVAV99 commented Aug 30, 2024

I would recommend that everyone that needs to support a specific device or set of devices do so by configuring their build tool so it transforms or transpiles the code so it's compatible with that device.

It's unreasonable to expect that packages stick with obsolete syntax when it would only affect a tiny subset of the users.

@pariharkaran
Copy link

Got fixed by downgrading to v14.1.3

@adrai
Copy link
Member

adrai commented Oct 13, 2024

@anniewey @pariharkaran did you try v15.0.3 ?

@anniewey
Copy link

@adrai din try v15.0.3 but i managed to get past the error using v15.0.2

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

6 participants
@adrai @VIKTORVAV99 @anniewey @jvictor98 @pariharkaran and others