Skip to content

i18n.services.formatter sometimes shows undefined #2318

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

Closed
scotttalkbox opened this issue Mar 3, 2025 · 2 comments
Closed

i18n.services.formatter sometimes shows undefined #2318

scotttalkbox opened this issue Mar 3, 2025 · 2 comments
Labels

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.

Copy link

stale bot commented Apr 26, 2025

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Apr 26, 2025
@stale stale bot closed this as completed May 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants