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

[React] bug: properties are not available when the component calls connectedCallback when using the react wrapper #458

Open
3 tasks done
dgonzalezr opened this issue Aug 20, 2024 · 5 comments
Labels
type: bug Something isn't working

Comments

@dgonzalezr
Copy link
Contributor

dgonzalezr commented Aug 20, 2024

Prerequisites

Stencil Version

4.20.0

Stencil Framework Output Target

React

Stencil Framework Output Target Version

0.6.0

Current Behavior

After the latest changes carried on this PR, when using the library react output target, the properties are not available when the component calls connectedCallback, they are undefined, and become available when calling componentWillLoad. Eg:

<MyComponent first="John" middle="Doe" />

this.first and this.middle are undefined when connectedCallback is called.

image

Important

Please, note that this only happens when using the wrapper component generated by v0.6.0 of @stencil/react-output-target. If I use the web component, the properties values are available on connectedCallback. For the previous version of the output target, everything works as expected.

Expected Behavior

Properties should be accessible on connectedCallback if their value has been set directly.

Steps to Reproduce

Follow the steps described in the Issue 1 of the reproduction code below

Code Reproduction URL

https://github.com/dgonzalezr/nx-stencil

Additional Information

No response

@ionitron-bot ionitron-bot bot added the triage label Aug 20, 2024
Copy link

ionitron-bot bot commented Aug 20, 2024

Thanks for the issue!

This project is currently maintained for the purposes of supporting Ionic Framework. At this time, only new issues & pull requests that support Ionic Framework will be prioritized. For the latest updates regarding the maintenance status of this project, please see this section of the project's README

@dgonzalezr
Copy link
Contributor Author

I just tested with the latest react-output-target v0.7.1, and the issue persists.

@christian-bromann christian-bromann added type: bug Something isn't working and removed triage labels Aug 29, 2024
@christian-bromann
Copy link
Member

@dgonzalezr thanks for filing the issue. Our team hasn't been able to take a look at this yet. If you are blocked by this I suggest to help us find a resolution to this as we can't provide an ETA due to a lot of competing resources. We are happy to assist on any technical questions. Cheers!

@dgonzalezr
Copy link
Contributor Author

dgonzalezr commented Aug 29, 2024

Hi @christian-bromann, thank you for jumping in. I'm not completely blocked by this issue, as I can shift the logic to componentWillLoad() as a workaround. However, my concern is that componentWillLoad() is triggered only once, whereas connectedCallback() is activated each time the component is attached or moved within the DOM. I will try to make some time and look into it. In the Discord thread @sean-perkins suggested:

For the other issue it is possible we need to adjust our really slim wrapper around @lit/react to wait for the element to be defined before rendering the component wrapper:

if (typeof defineCustomElement !== 'undefined') {
defineCustomElement();
}

Maybe I can use it as a starting point 🙂

@christian-bromann
Copy link
Member

Maybe I can use it as a starting point 🙂

Yes, awesome! Let me know if you have any questions.

@dgonzalezr dgonzalezr changed the title [react-output-target] bug: properties are not available when the component calls connectedCallback when using the react wrapper [React] bug: properties are not available when the component calls connectedCallback when using the react wrapper Aug 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants