Closed maxYurchenko closed 3 years ago
Hi,
I'm getting a feeling that I've been a bit heavy handed with the readonly
keyword. I will make a change to Content
to remove some of the readonly
.
In the beginning of this project, this was an internal library here at Item. And to encourage immutability (you have to copy an object to change it), a lot of fields were set to readonly
.
That was the background story, here is how to work around it:
contentLib.modify<Article>({
key: content._id,
editor: (c: Content<Article>) => {
return {
displayName: newDisplayName ?? c.displayName,
...c
}
}
});
displayName can be edited by content.modify, what leads to an error
Cannot assign to 'displayName' because it is a read-only property
Is there any way to solve this now?