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

i18n.services.formatter sometimes shows undefined #2318

Open
scotttalkbox opened this issue Mar 3, 2025 · 1 comment
Open

i18n.services.formatter sometimes shows undefined #2318

scotttalkbox opened this issue Mar 3, 2025 · 1 comment

Comments

@scotttalkbox
Copy link

scotttalkbox commented Mar 3, 2025

🐛 Bug Report

i18n.services.formatter shows undefined upon loading via useEffect. When I tried to use i18n as the mere dependency, some keys are failed to hydrate

To Reproduce

Image

  useEffect(() => {
    // Check if i18n and all required nested properties exist
    if (i18n?.services?.formatter) {
      i18n.services.formatter.add("lowercase", (value, lng, options) => {
        return value?.toLowerCase();
      });
    }
  }, [i18n.services.formatter]);

Expected behavior

Expected the keys are hydrated correctly without application error

Your Environment

  • i18next version: i.e. 22.4.15
  • os: Mac
@adrai
Copy link
Member

adrai commented Mar 3, 2025

it's undefined if the i18next instance is not initialized yet.

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

2 participants