QuiiBz / next-international

Type-safe internationalization (i18n) for Next.js
https://next-international.vercel.app
MIT License
1.19k stars 52 forks source link

Failed to execute 'removeChild' on 'Node' when using `useChangeLocale` and `useCurrentLocale` #401

Open ARiyou2000 opened 1 month ago

ARiyou2000 commented 1 month ago

Describe the bug before using useChangeLocale and useCurrentLocale everything is fine. but after using these hooks, I will get the following error:

NotFoundError: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node.

To Reproduce

"use client";

import { createI18nClient } from "next-international/client";

import { supportedLangs } from "@/types/supportedLangs";

export const {
  useI18n,
  useScopedI18n,
  useChangeLocale,
  useCurrentLocale,
  I18nProviderClient,
} = createI18nClient<Record<supportedLangs, () => Promise<any>>>({
  en: () => import("../../dictionaries/en"),
  fa: () => import("../../dictionaries/fa"),
});

const LanguageSelect = (props: SelectProps) => {
  const currentLocale = useCurrentLocale();
  const changeLocal = useChangeLocale();

  return (
    <div key={"langDiv"}>
      <Select
        key={"langSelect"}
        value={currentLocale}
        onValueChange={changeLocal}
        {...props}>
        <SelectTrigger className="w-[180px]">
          <SelectValue placeholder="lang" />
        </SelectTrigger>
        <SelectContent>
          <SelectItem value="fa">Fa</SelectItem>
          <SelectItem value="ru">RU</SelectItem>
          <SelectItem value="en">English</SelectItem>
        </SelectContent>
      </Select>
    </div>
  );
};

Expected behavior I should get result and not error

Screenshots Screenshot from 2024-05-11 09-44-09

About (please complete the following information):