Skip to content

bug: react-output-target 0.8.1 - @Prop is not yet set in connectedCallback step #588

Open
@dpellier

Description

@dpellier

Prerequisites

Stencil Version

4.23.0

Stencil Framework Output Target

React

Stencil Framework Output Target Version

0.8.1

Current Behavior

When using the react bundled component, @Prop are not set on the connectedCallback step (though attributes are).
This is visible when your @Prop is using camelCase, ex: @Prop() myProp: string;

Ex:

<MyComponent
  myProp="jsx case"
  my-prop="html case"
/>

connectedCallback() {
  console.log(`connectedCallback > myProp: ${this.myProp}`) // => print "html case"
}

componentWillLoad() {
  console.log(`componentWillLoad > myProp: ${this.myProp}`) // => print "jsx case"
}

Expected Behavior

Props should be accessible during the connectedCallback lifecycle step, as it was the case in previous version.

<MyComponent
  myProp="jsx case"
/>

connectedCallback() {
  console.log(`connectedCallback > myProp: ${this.myProp}`) // => should print "jsx case"
}

Steps to Reproduce

  • Follow the project creation guide for React: https://stenciljs.com/docs/react
  • Add a camelCase Prop to the component
  • Build stencil lib and react lib
  • Use the React component in an app

(you can clone this reproduction project to reproduce it more quickly, the steps are detailed in the README)

Code Reproduction URL

https://github.com/dpellier/stencil-react-connected-callback-issue

Additional Information

The issue did appear when migrating from v0.5.3 to 0.8.1.

By diggin a bit, we ended up on the following https://lit.dev/docs/frameworks/react/#how-it-works
Seems this may be caused by moving to a lit wrapper that attachs props later on the lifecycle.

But this is quite a major breaking changes if this means we can't use the connectedCallback the same way anymore.

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wanteda good issue for the communitypackage: react@stencil/react-output-target packagetype: bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions