salesforce / lwc

⚡️ LWC - A Blazing Fast, Enterprise-Grade Web Components Foundation
https://lwc.dev
Other
1.64k stars 392 forks source link

@wire does not like computed property keys #4988

Open wjhsf opened 2 hours ago

wjhsf commented 2 hours ago

Description

@wire, in the engine-server implementation, assumes that the identifier being decorated is not a computed value, resulting in the wrong prop being updated.

In the below example, we want to update the computed symbol property for Symbol(please). Instead, we end see that the component's "symbol" property is being updated, replacing the value we though we'd have.

const symbol = Symbol('please');
export default class extends LightningElement {
    symbol = 'nope';

    @wire(adapter, {value: '123'})
    [symbol];

    get symbolIdentifier () {
        return this.symbol ?? 'unset';
    }

    get symbolValue () {
        return this[symbol] ?? 'unset';
    }
}

playground

Steps to Reproduce

https://playground.lwc.dev

const your => (code) => here;

Expected Results

Actual Results

Browsers Affected

Version

Possible Solution

Additional context/Screenshots Add any other context about the problem here. If applicable, add screenshots to help explain.

nolanlawson commented 2 hours ago

This repros in engine-dom as well.