Skip to content

Using key as an @api property is a silent no-op #1017

@apapko

Description

@apapko

Description

A customer brought up an issue with a public property that never rehydrates.
Issue: ability to decorate a special 'key' property with @api.

playground link: https://playground.lwcjs.org/projects/mY3ddUxFH/4/edit

ex:

// parent.html
<c-child key={childKey}></c-child>

// parent.js
export default class Child extends LightningElement {
     get childKey() {
          return 'key value from parent';
     }
}

// child.js
export default class Child extends LightningElement {
     @api key = 'my key'; 
}

// child.html
<template>
    <h2>key value from parent: {key}</h2>
</template>

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions