@sheet-i18n/react-client 1.5.0-canary.2 → 1.5.0-canary.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -439,7 +439,6 @@ var LocaleStorageManager = class {
439
439
  };
440
440
  this.setLocale = (locale) => {
441
441
  this.storageService.setItem(this.localeStorageKey, locale);
442
- this.i18nStore.setCurrentLocale(locale);
443
442
  this.observerManager.notify(locale);
444
443
  };
445
444
  this.initializeCurrentLocale();
@@ -456,26 +455,25 @@ var getLocaleStorageManager = (i18nStore, storage) => {
456
455
 
457
456
  // src/hooks/useLocaleStorage.ts
458
457
  var import_react3 = require("react");
458
+ var LISTENER_ID = "LOCALE_STORAGE_LISTENER_ID";
459
459
  function useLocaleStorage(localeStorageManager) {
460
460
  var _a;
461
461
  const [locale, setLocale] = (0, import_react3.useState)((_a = localeStorageManager == null ? void 0 : localeStorageManager.getLocale) == null ? void 0 : _a.call(localeStorageManager));
462
- const listenerIdRef = (0, import_react3.useRef)(
463
- `LOCALE_STORAGE_LISTENER_${Math.random().toString(36).substring(2, 11)}`
464
- );
462
+ console.log("\u2705 locale in useLocaleStorage", locale);
465
463
  (0, import_react3.useEffect)(() => {
466
464
  var _a2;
467
- const listenerId = listenerIdRef.current;
468
465
  (_a2 = localeStorageManager == null ? void 0 : localeStorageManager.observerManager) == null ? void 0 : _a2.addListener({
469
- listenerId,
466
+ listenerId: LISTENER_ID,
470
467
  listener: (newLocale) => {
468
+ console.log("\u2705 did you update the locale?", newLocale);
471
469
  setLocale(newLocale);
472
470
  }
473
471
  });
474
472
  return () => {
475
473
  var _a3;
476
- (_a3 = localeStorageManager == null ? void 0 : localeStorageManager.observerManager) == null ? void 0 : _a3.removeListener(listenerId);
474
+ (_a3 = localeStorageManager == null ? void 0 : localeStorageManager.observerManager) == null ? void 0 : _a3.removeListener(LISTENER_ID);
477
475
  };
478
- }, [localeStorageManager]);
476
+ }, []);
479
477
  return { locale };
480
478
  }
481
479
 
package/dist/index.mjs CHANGED
@@ -416,7 +416,6 @@ var LocaleStorageManager = class {
416
416
  };
417
417
  this.setLocale = (locale) => {
418
418
  this.storageService.setItem(this.localeStorageKey, locale);
419
- this.i18nStore.setCurrentLocale(locale);
420
419
  this.observerManager.notify(locale);
421
420
  };
422
421
  this.initializeCurrentLocale();
@@ -432,27 +431,26 @@ var getLocaleStorageManager = (i18nStore, storage) => {
432
431
  };
433
432
 
434
433
  // src/hooks/useLocaleStorage.ts
435
- import { useEffect as useEffect2, useState as useState2, useRef } from "react";
434
+ import { useEffect as useEffect2, useState as useState2 } from "react";
435
+ var LISTENER_ID = "LOCALE_STORAGE_LISTENER_ID";
436
436
  function useLocaleStorage(localeStorageManager) {
437
437
  var _a;
438
438
  const [locale, setLocale] = useState2((_a = localeStorageManager == null ? void 0 : localeStorageManager.getLocale) == null ? void 0 : _a.call(localeStorageManager));
439
- const listenerIdRef = useRef(
440
- `LOCALE_STORAGE_LISTENER_${Math.random().toString(36).substring(2, 11)}`
441
- );
439
+ console.log("\u2705 locale in useLocaleStorage", locale);
442
440
  useEffect2(() => {
443
441
  var _a2;
444
- const listenerId = listenerIdRef.current;
445
442
  (_a2 = localeStorageManager == null ? void 0 : localeStorageManager.observerManager) == null ? void 0 : _a2.addListener({
446
- listenerId,
443
+ listenerId: LISTENER_ID,
447
444
  listener: (newLocale) => {
445
+ console.log("\u2705 did you update the locale?", newLocale);
448
446
  setLocale(newLocale);
449
447
  }
450
448
  });
451
449
  return () => {
452
450
  var _a3;
453
- (_a3 = localeStorageManager == null ? void 0 : localeStorageManager.observerManager) == null ? void 0 : _a3.removeListener(listenerId);
451
+ (_a3 = localeStorageManager == null ? void 0 : localeStorageManager.observerManager) == null ? void 0 : _a3.removeListener(LISTENER_ID);
454
452
  };
455
- }, [localeStorageManager]);
453
+ }, []);
456
454
  return { locale };
457
455
  }
458
456
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sheet-i18n/react-client",
3
- "version": "1.5.0-canary.2",
3
+ "version": "1.5.0-canary.3",
4
4
  "description": "a client package for react modules used by sheet-i18n",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -25,8 +25,8 @@
25
25
  },
26
26
  "license": "ISC",
27
27
  "dependencies": {
28
- "@sheet-i18n/errors": "1.8.0-canary.0",
29
28
  "@sheet-i18n/shared-utils": "1.8.0-canary.0",
29
+ "@sheet-i18n/errors": "1.8.0-canary.0",
30
30
  "@sheet-i18n/react-core": "1.5.0-canary.0"
31
31
  },
32
32
  "devDependencies": {