The instance of this class is created like this:
this.example = new Example(this.prop1, this.prop2);
Then, I'm trying to destructure these properties like this:
export default class Example {
constructor(params) {
const { prop1, prop2 } = params;
console.log('params', params);
console.log('prop1', prop1);
console.log('prop2', prop2);
}
}
When I log these values, params
returns data, but prop1
and prop2
are undefined
, and they didn't properly destructure. Is it possible that the way I'm passing this data to the class won't work?