We will expand our UI, and give the user the possibility to edit his wishlist. We will use the earlier defined actions. We also will use model clones only to modify data temporarily, and after approving the changes, apply them back to the original model.
In this lesson you will learn:
clone
to create a full, deep clone of any model instanceapplySnapshot
to update the state of a model instance given a snapshot.const Model = types.model({ name: types.string });
const model = Model.create({ name: 'Gar' });
const cloned = clone(model);
console.log((cloned === model)); //why is this false?????
Thank you :)
Clones are per definition not the same instance as the original. If it was, it wouldn't be a clone :) So if you clone "Gar", then there are two different "Gar"s with the same properties, but you could start updating them individually.
Op di 20 mrt. 2018 om 16:37 schreef Gar notifications@egghead.io:
yes indeed. Thanks!!