I'm trying to merge the props from values
into this
.
The following throws an error. How can I do this?
this = {...this, ...values}
You could extend this
with Object.assign method:
class Foo {
constructor (props) {
Object.assign(this, props);
}
}
const foo = new Foo({ a: 1 });
console.log(foo.a); // 1