Skip to content

bug: undetected initial prop value on Angular #6373

@mamillastre

Description

@mamillastre

Prerequisites

Stencil Version

=4.36.0

Current Behavior

Since Stencil 4.36.0, an initial prop value can be undetected on a dynamically set Angular component.

For example, I use the following code to emulate the dynamic first prop value:

<my-component [first]="'issue'"></my-component>

I have the following logs:

@Prop() first!: string;
@Watch('first')
firstChanged() {
  console.log('CHANGE', this.first);
}

connectedCallback() {
  console.log('connectedCallback', this.first);
}

componentWillLoad() {
  console.log('componentWillLoad', this.first);
}

componentDidLoad() {
  console.log('componentDidLoad', this.first);
}

render() {
  console.log('render', this.first);
  ...
}

In runtime:

Image

The value comes only at the second rendering, the prop has not been initialized before componentWillLoad and the Watch() method has not been called.
The prop update seems to be undetected but fire a rerender.

Note: I reproduced this issue only when the component is on a child routing page and when the app is loaded on this page (See reproduction steps).

Expected Behavior

The prop is available on componentWillLoad OR the Watch() method is called.

System Info

System: node 20.18.3
Platform: darwin (24.6.0)
CPU Model: Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz (12 cpus)
Compiler: /stencil-demo/packages/elements/node_modules/@stencil/core/compiler/stencil.js
Build: 1752598220
Stencil: 4.36.0 🎊
TypeScript: 5.5.4
Rollup: 4.34.9
Parse5: 7.2.1
jQuery: 4.0.0-pre
Terser: 5.37.0

Steps to Reproduce

Image
  • Refresh the page (on the test page)
  • The Watch() method is not called
Image

If the stencil component is in the Angular root component (projects/angular-app/src/app/app.component.html), the prop is initialized on componentWillLoad.

Image

Code Reproduction URL

https://github.com/mamillastre/stencil-demo/tree/angular-issue

Additional Information

The issue seems to come from Stencil v3.36.0.
Workaround: stay on the v3.35.3
I didn't try to reproduce on Vue or React.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bug: ValidatedThis PR or Issue is verified to be a bug within StencilHas WorkaroundThis PR or Issue has a work around detailed within it.Help Wanted

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions