You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using React with Redux and I am trying to merge like this (being "state", an Immutable object): state.merge({ isFetchingCategories: false, categoriesErrorMessage: null, categories }
Where categories is of type Category[]. The problem is in seamless-immutable.development.js line 659: for (var key in obj) { if (Object.getOwnPropertyDescriptor(obj, key)) { clone[key] = Immutable(obj[key], undefined, stackRemaining); } }
When obj is one of the elements of categories, the "Object.getOwnPropertyDescriptor(obj, key)" will be undefined for Category class' getters (Id, Display, Name), the rest of the private properties are taken into consideration. So, the problem is that I end up with a cloned element ("clone" variable in the code) which do not correspond to the class, since the getters are not there...
How can I fix this? How can we merge classes instances?
The text was updated successfully, but these errors were encountered:
Problem:
I have following class:
`class Category {
static ObjectMapToCategory(id: number, display: string, name: string): Category {
return new Category(id, display, name);
}
constructor(private id: number, private display: string, private name: string) {
}
get Id(): number {
return this.id;
}
get Display(): string {
return this.display;
}
get Name(): string {
return this.name;
}
};`
I am using React with Redux and I am trying to merge like this (being "state", an Immutable object):
state.merge({ isFetchingCategories: false, categoriesErrorMessage: null, categories }
Where categories is of type Category[]. The problem is in seamless-immutable.development.js line 659:
for (var key in obj) { if (Object.getOwnPropertyDescriptor(obj, key)) { clone[key] = Immutable(obj[key], undefined, stackRemaining); } }
When obj is one of the elements of categories, the "Object.getOwnPropertyDescriptor(obj, key)" will be undefined for Category class' getters (Id, Display, Name), the rest of the private properties are taken into consideration. So, the problem is that I end up with a cloned element ("clone" variable in the code) which do not correspond to the class, since the getters are not there...
How can I fix this? How can we merge classes instances?
The text was updated successfully, but these errors were encountered: