examples icon indicating copy to clipboard operation
examples copied to clipboard

Factory create duplicates in react-typescript exemple

Open clementoriol opened this issue 5 years ago • 3 comments

Hi, I was looking around in the example files to get a better understanding on how to get type-safe factories, and realized that the factory in the react-typescript always creates the same object.

I was expecting :

server.createList("person", 20);

to create 20 unique Person objects, but it creates 20 identical ones.

Is this expected ? Modifying the factory to use regular functions instead of getters works, but I'm a bit confused about how to type it properly.

clementoriol avatar Dec 24 '20 13:12 clementoriol

I have the same issue. I'm ha ving some trouble figuring out how to modify it to show different people.

GregBelle avatar Dec 25 '20 04:12 GregBelle

Hey @GregBelle , found a way to fix it, you can check what I did on my PR: https://github.com/miragejs/examples/pull/11

clementoriol avatar Dec 25 '20 08:12 clementoriol

@clementoriol Thanks! I copied in your updates locally and was able to follow the pattern for my own factory.

GregBelle avatar Dec 27 '20 04:12 GregBelle