nanostores / i18n

A tiny (≈600 bytes) i18n library for React/Preact/Vue/Svelte
MIT License
229 stars 12 forks source link

Error while using useStore #25

Open andvlad opened 1 year ago

andvlad commented 1 year ago

Hello.

I'm using Preact + vite-plugin-ssr and useStore gives me an error: TypeError: Cannot read properties of undefined (reading '__H') So far, I haven't been able to figure out what the problem is. Maybe I'm doing something wrong. Example

It would be great if anyone has any ideas Thanks

ai commented 1 year ago

How do you server JSON file with translations?

andvlad commented 1 year ago

Actually I don't want to use JSON files for now. I want to use default translations in the component. But createI18n.get is mandatory, so I just put there cross-fetch request which doesn't return anything, because I thought it would be leveraged only on locale changes. And I don't change locales for now. I also tried to directly import JSON files with import(). But error still the same (I created some placeholder JSON files for this)

ai commented 1 year ago

Sorry, have no idea. Code looks fine. Maybe some strange bug with Preact?

andvlad commented 1 year ago

I copied the code from useStore to the local hook and it started working. (I updated example) Quite strange thing