expo-starter icon indicating copy to clipboard operation
expo-starter copied to clipboard

"Store.name" creates duplicates once published

Open gerardomaranan opened this issue 2 years ago • 3 comments

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'],
    });

gerardomaranan avatar May 11 '22 19:05 gerardomaranan

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.

kanzitelli avatar May 11 '22 21:05 kanzitelli

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 avatar May 12 '22 07:05 gerardomaranan

@gerardomaranan yep, that would be great! Initially, it was implemented as a pure string as you mentioned in the question.

kanzitelli avatar May 12 '22 15:05 kanzitelli