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

bug: componentDidLoad is called in parent before children have loaded #3580

Closed
3 tasks done
mpayson opened this issue Sep 2, 2022 · 4 comments · Fixed by #5941
Closed
3 tasks done

bug: componentDidLoad is called in parent before children have loaded #3580

mpayson opened this issue Sep 2, 2022 · 4 comments · Fixed by #5941
Labels
Bug: Validated This PR or Issue is verified to be a bug within Stencil

Comments

@mpayson
Copy link

mpayson commented Sep 2, 2022

Prerequisites

Stencil Version

2.17.4

Current Behavior

The componentDidLoad lifecycle method is called in a parent before its children have loaded

Expected Behavior

componentDidLoad is called after all the children have loaded as described in the documentation: https://stenciljs.com/docs/component-lifecycle#lifecycle-hierarchy

Steps to Reproduce

  1. Clone the reproduction URL
  2. Install dependencies yarn
  3. Run then open the demo page yarn vite
  4. Open the developer console
  5. Notice "PARENT LOADED" is logged before "CHILD LOADED"

Note, the demo uses the index.html page and loads the built stencil components. The source code for the stencil components is in the src/ directory.

Code Reproduction URL

https://github.com/mpayson/stencil-debug

Additional Information

I was also able to reproduce this issue with another application setup (React + Webpack). Thanks!

@ionitron-bot ionitron-bot bot added the triage label Sep 2, 2022
@alicewriteswrongs
Copy link
Contributor

Hello @mpayson, thanks for filing this issue and for providing a reproduction repo! It's a big help for us when triaging issues.

I'm able to confirm the behavior that you describe and that it doesn't match up with what's described in the Stencil documentation. I'm going to label this so it gets ingested into our backlog and the Stencil team can prioritize it.

Thanks again for filing!

@alicewriteswrongs alicewriteswrongs added the Bug: Validated This PR or Issue is verified to be a bug within Stencil label Sep 6, 2022
@ionitron-bot ionitron-bot bot removed the triage label Sep 6, 2022
@pierrebaronqumu
Copy link

This is still present in 4.0.5, I experienced this in our UI-Kit. It fails with synchronous componentWillLoad() and componentDidLoad() (compared to the initial GitHub reproduction).

@pierrebaronqumu
Copy link

I ran some tests and I noticed the following:

  • bug is still present in 4.2.1
  • bug is not present when using the dist build
  • bug is present when using the dist-custom-elements build, no matter the customElementsExportBehavior selected.

@christian-bromann
Copy link
Member

christian-bromann commented Aug 26, 2024

A fix for this bug has been published in Stencil v4.21.0!

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug: Validated This PR or Issue is verified to be a bug within Stencil
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants