Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

renderedCallback fires inconsistently after disconnect+reconnect in native lifecycle #4057

Open
nolanlawson opened this issue Mar 13, 2024 · 0 comments
Labels

Comments

@nolanlawson
Copy link
Contributor

nolanlawson commented Mar 13, 2024

In native lifecycle, if you have a list of components using for:each, and the list is reordered (which causes LWC to remove+reconnect a list item), you get the following result:

  1. renderedCallback fires for the list item component
  2. renderedCallback does not fire for any children of the list item component
<template for:each={items} for:item="item">
  <x-item-wrapper key={item}></x-item-wrapper> <!-- fires renderedCallback -->
    #shadow-root
      <x-item></x-item> <!-- does NOT fire renderedCallback -->
</template>

Repro: nolanlawson@0c7dff5

It feels like we should either 1) consistently fire renderedCallback or 2) consistently not fire renderedCallback in this case.

In synthetic lifecycle, neither renderedCallback nor connectedCallback nor disconnectedCallback would fire after list reordering.

Note: this also applies to manually calling removeChild+appendChild, not just for:each. But it's most commonly seen in for:each.

@nolanlawson nolanlawson changed the title renderedCallback fires inconsistently after list reordering in native lifecycle renderedCallback fires inconsistently after disconnect+reconnect in native lifecycle Mar 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant