expo-starter
expo-starter copied to clipboard
"Store.name" creates duplicates once published
Newbie here!
Once code has been published some SomeStore.name
are possibly duplicated and causes issue on hydrateStores
.
Noticed this while creating multiple IStore classes. The app keeps getting stuck on splash screen in Production mode and failing at hydrateStores
, and then I tried logging store each store loop iteration under said method and noticed t
is being hydrated multiple times hence failing to hydrate one or more stores properply. The same code works fine in dev mode (probably because names aren't minified here).
Am I doing something wrong? Or any configurations I might've missed?
Worked around the issue by hard-coding name instead of using Function.name
.
From:
export class SampleStore implements IStore {
...
makePersistable(this, {
name: SampleStore.name,
properties: ['someProperty'],
});
...
To:
makePersistable(this, {
name: "SampleStore",
properties: ['someProperty'],
});
Hey @gerardomaranan! That's quite strange, I've never faced anything similar before. Are you sure that you are giving different names to store classes and changing it also in makePersistable
? Because FooClass.name
should always return the name of the class and if they are all different, makePersistable
should work fine.
Hey @kanzitelli, yup I'm pretty sure I named the store classes differently as it'll throw errors if I do not. I'll try and replicate it on a new project. I'll let you know. Thanks!
@gerardomaranan yep, that would be great! Initially, it was implemented as a pure string as you mentioned in the question.