Loading

Lists fail to render due to invalid key values

Data pubblicazione: Sep 12, 2024
Descrizione

Starting in Summer ‘24, iteration keys in Lightning Web Components must be a string or a number. Components that use iteration keys of any other type can trigger runtime exceptions. For example, if you set a list iteration key to an object, the list won’t render in certain edge cases.

Risoluzione

To ensure that your components render correctly, only set iteration keys to either a string or a number.

If a component throws one of these exception messages, make sure that its iteration key is set to a valid value.

  • TypeError: Cannot read properties of undefined (reading '0')
  • TypeError: Failed to execute 'removeChild' on 'Node': parameter 1 is not of type 'Node'

You can also validate your components’ iteration keys by running your application in debug mode. If a component that uses an iteration key throws any of these error messages in the DevTools console, verify that the key is a string or a number.

Error: [LWC error]: Invalid key value "[object Object]" in [object:vm LightningElement (1)]. Key must be a string or number.

Numero articolo Knowledge

001979875

 
Caricamento
Salesforce Help | Article