Value-type models act like primitives. When a value-type model is attached to a tree, it is automatically cloned if it already has a parent. This prevents the error of a single node attempting to have multiple parents.
To enable this behavior, pass { valueType: true } as the second argument to the Model constructor.
Note: Because it is a clone, modifying the new instance will not affect the original instance.
@model("myApp/Color")
class Color extends Model(
{
r: prop<number>(),
g: prop<number>(),
b: prop<number>(),
},
{
valueType: true,
}
) {}