chore(deps): Update dependency react-i18next to v18 - autoclosed #332
No reviewers
Labels
No labels
dependencies
major
security-pin
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
trails-cool/trails!332
Loading…
Reference in a new issue
No description provided.
Delete branch "renovate/react-i18next-18.x"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This PR contains the following updates:
^17.0.9→^18.0.0Release Notes
i18next/react-i18next (react-i18next)
v18.0.1Compare Source
@types/reactas an optional peer dependency. The type declarations import fromreact, and with pnpm's global virtual store (virtualStoreType: global) TypeScript resolved that to the untypedreact/index.js, so every React type in them becameany: wrong props compiled, callback parameters failed with TS7006. Under the default pnpm layout it only worked through pnpm's hidden hoisting. The range is*, so projects without TypeScript install nothing extra and an older@types/reactdoes not make npm fail (#1948)>= 27.0.1), which keeps at most 1000 formatters in each cached formatv18.0.0Compare Source
Released together with i18next 27. The migration guide lists every change with what to do: https://react.i18next.com/latest/migrating-v17-to-v18
Breaking changes
>= 27.0.0) and React 18 or later (peer>= 18.0.0). React 16 and 17 apps stay on react-i18next 17: on i18next 27, use react-i18next 17.1.13 or later (it brings the types of thereactinit options), or 18.useSyncExternalStorecomes from React itself, souse-sync-external-storeis no longer a dependency.Transoutput no longer depends oninterpolation.escapeValue: it always decodes HTML entities after parsing, asIcuTransdoes, in text and in attribute values, both withreact.unescape(attribute values used the built-in decoder before). With i18next's defaultescapeValue: true, a valueTom & Jerryrendered asTom & Jerryand a date17/12/2025as17/12/2025; both now render as written, and so do entities in the translation itself (&,<, , ...). Values still render as text, never as markup (since 17.1.10). TheshouldUnescapeprop andreact.transDefaultProps.shouldUnescapeare ignored and warn (DEPRECATED_OPTION, in development and withdebug: true); remove them. Snapshot tests that contain entities insideTransoutput need an update (#1903, #1893).TransandIcuTransre-render on language change by themselves: they subscribe to thereact.bindI18n(defaultlanguageChanged) andreact.bindI18nStoreevents, likeuseTranslation. Before, they only updated when a parent re-rendered (#1710). They still neither load translations nor suspend; with atprop, thattstill decides the language.TransWithoutContextandIcuTransWithoutContextstay hook-free.reactoptions of an instance stay on that instance.initReactI18nextcopied them into module-wide defaults, so a second instance withoutreactoptions inherited, for example, the first one'suseSuspense: false. Set them on every instance, or callsetDefaults()once.i18nreturned byuseTranslation(and passed bywithTranslationandTranslation) forwards reads and writes to the instance. It was a copy taken when the language changed, so afterawait i18n.changeLanguage('de')the copy still saiden, and properties set on it never reached the instance. It is still a new object whenever the language changes, for dependency arrays and the React Compiler. Because the old object now reads the current language too, a check likeprevProps.i18n.language !== this.props.i18n.language(or the language of ausePrevious(i18n)) no longer sees a change: compare the objects (prevProps.i18n !== this.props.i18n) or keep the previous language yourself.useSSRandwithSSRcall i18next'shydrate()instead of writingresourceStore.data,options.ns,initializedStoreOnce,isInitializedandinitializedLanguageOncethemselves. Same behavior with real instances, including the opt-out for cloned instances. Test mocks ofi18nused withuseSSR/withSSRnow need ahydratemethod, mocks that load beforeinit()needonce, and mocks used withTransorIcuTransneedonandoff, since both subscribe to events now (withbindI18nStoreset, alsostore.onandstore.off): a minimal mock like{ t, options, language }throwsi18n.on is not a function.react-i18next/icu.macroBabel macro (deprecated since 17.0.21) is removed, with the placeholder exportsdate,time,number,select,pluralandselectOrdinal. WriteIcuTransdirectly.HTMLAttributes['children']augmentation forallowObjectInHTMLChildrenmoved to the opt-inreact-i18next/augment-react. Default installs no longer change React's DOM types. WithallowObjectInHTMLChildren: true, addimport 'react-i18next/augment-react';next to yourCustomTypeOptions; with current@types/reactit needsskipLibCheck: true(#1928).I18nContextis typed{ i18n: i18n; defaultNS?: string | string[] } | undefined, as at runtime:useContext(I18nContext)isundefinedoutside anI18nextProvider.getI18n()keeps its type.reactinit options. i18next 27 keeps an emptyReactOptionsinterface that react-i18next fills in, soimport type { ReactOptions } from 'i18next'keeps working, andReactOptionsis also exported fromreact-i18next. ThedefaultTransParentdocs no longer claim a'div'default.i18next(load i18next's UMD build first) and shrinks from 71.3 KB to 26.2 KB minified. The AMD build (dist/amd) is removed; AMD loaders can use the UMD file.engines.nodeis>=22, and the build targets ES2020 syntax with a fixed browser list instead of browserslistdefaults.Other changes
react-serverexport condition forreact-i18next. In a React Server Component,import { Trans } from 'react-i18next'failed withcreateContext is not a function; it now resolves to an entry withTransandIcuTrans(the variants without React context),TransWithoutContext,IcuTransWithoutContext,nodesToString,initReactI18next,setI18n/getI18nandsetDefaults/getDefaults. Hooks, HOCs,Translation,I18nextProviderand the SSR helpers stay client-only, so importing them there is a build error. Without ani18nprop, the serverTransandIcuTransuse the global instance (the oneinitReactI18nextregistered), which is the wrong one with an instance per request: pass that instance asi18n(tis optional). Atalone is not enough, because atfromgetFixedTcarries no instance. In development and withdebug: truethey warn about it (GLOBAL_INSTANCE_ON_SERVER) (#1759, #1840).<0/>) with children of its own is no longer remounted on every render.Transcreated a new component type for it each time, so its state and effects were reset.cloneInstance(), for example one per request in i18next-http-middleware) share their parent's, as they share its logger, so they do not repeat them.init()usesi18n.once('initialized')instead of removing its listener with a delay.keySeparator: falseand a key prefix (useTranslation(ns, { keyPrefix }),getFixedT), thevaluesofTransandIcuTransare typed from the right key. The prefix and the key were joined with the textfalse(nestedfalsec), so no variables were checked; they are now joined with., asgetFixedTdoes.useSSRtakes its third argument{ i18n }, and theuseTranslationoptions takebindI18nStore, as at runtime.ErrorCodelistsI18N_NOT_INITIALIZED,ICU_TRANS_RENDER_ERRORandGLOBAL_INSTANCE_ON_SERVER.fileswhitelist replaces.npmignore;@babel/runtimeis no longer a dependency.v17.1.13Compare Source
reactinit options keep their types with i18next 27. i18next 27 declaresReactOptions(the type ofi18next.init({ react })) as an empty interface and leaves its shape to react-i18next, so with react-i18next 17 thereactoptions were no longer checked andgetDefaults().useSuspensedid not compile. react-i18next now declares them itself, with exactly the types i18next 26 has: TypeScript accepts the repeated declaration on i18next 26, and on i18next 27 it fills in the empty interface. Nothing changes with i18next 26.v17.1.12Compare Source
<Trans>is fast again with large resources. Since 17.0.2 the return type of the key was a type parameter ofTrans, so TypeScript also computed it for every key of the namespace: with 50 namespaces of 200 keys, one<Trans>cost about 1.3 million more type instantiations than in 17.0.1, with or without avaluesprop. The return type is computed inside thevaluesprop again, as in 17.0.1, andvaluesstill only needs the variables of the giveni18nKey(#1913). The exportedTransPropstype loses theRetparameter added in 17.0.2, so its 6th parameter is the element propsEagain, as before 17.0.2. Thanks @leshaduduk (#1947), fixes #1946.Configuration
📅 Schedule: (in timezone Europe/Copenhagen)
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR has been generated by Mend Renovate CLI.
chore(deps): Update dependency react-i18next to v18to chore(deps): Update dependency react-i18next to v18 - autoclosedPull request closed