1

I have an LWC that takes in a configMap public property:

export default class ParentComponent extends LightningElement {
    @api
    get configMap() {
        return this._configMap;
    }
    set configMap(data) {
        this._configMap = data;
        this.optionsMap = data.optionsMap;
    }
}

I want to extend this component to add additional functionality to the setter, here's my code that seems to work:

export default class ExtendedComponent extends ParentComponent {
    @api
    get configMap() {
        return super.configMap;
    }
    set configMap(data) {
        super.configMap = data; // sets _configMap and optionsMap
        this.inputMap = data.inputMap;
    }
}

But I also get a console warning:

aura_proddebug.js:237 [LWC warning]: If property configMap decorated with @api in [object:vm undefined (32)] is used in the template, the value [object Object] set manually may be overridden by the template, consider binding the property only in the template.

If I duplicate the setter code instead of using super, I get no warning. But I'd rather not have to do that if I can avoid it. What's the correct way to accomplish this?

0

You must log in to answer this question.

Browse other questions tagged .