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

CamelCase @Prop() declaration don't work #114

Closed
1 of 3 tasks
jgw96 opened this issue Jan 9, 2018 · 7 comments
Closed
1 of 3 tasks

CamelCase @Prop() declaration don't work #114

jgw96 opened this issue Jan 9, 2018 · 7 comments
Assignees

Comments

@jgw96
Copy link
Contributor

jgw96 commented Jan 9, 2018

From @matteobortolazzo on January 7, 2018 12:57

Stencil version:

 @stencil/core@0.1.1-0

I'm submitting a:

Current behavior:
When declaring a @prop() in camelCase the value is undefined. If it's all lower case it works.

Expected behavior:
The variable should have a value.

Steps to reproduce:

New component,
Declare a prop in camelCase
Use the component and set the attribute
Check the prop value in the componentDidLoad method

Related code:

export class HomeButton {

   @Prop() isSelected: boolean;

  render() {
    return (
      <div class="tag-button">
        <div class="tag-button-image"></div>
      </div>
    );
  }

  componentDidLoad() {
      console.log(this.isSelected); // undefined
  }
}

Other information:

Copied from original issue: ionic-team/stencil#397

@jgw96 jgw96 self-assigned this Jan 9, 2018
@jgw96
Copy link
Contributor Author

jgw96 commented Jan 9, 2018

From @adamdbradley on January 9, 2018 3:14

As an attribute it should be <home-button is-selected="true">

@jgw96
Copy link
Contributor Author

jgw96 commented Jan 9, 2018

From @matteobortolazzo on January 9, 2018 8:31

I agree with you but I follow the docs.
stencil-props

@jgw96
Copy link
Contributor Author

jgw96 commented Jan 9, 2018

From @adamdbradley on January 9, 2018 12:33

Ok I see what you mean, this is a good question. In the example we're using JSX, and we can assign the element's properties. But if you're using the element in just HTML, and want to assign the value using attributes it uses dash case.

@jgw96 @jthoms1 any ideas how we can better document this? Or many any internal changes?

@jgw96
Copy link
Contributor Author

jgw96 commented Jan 9, 2018

From @matteobortolazzo on January 9, 2018 12:44

This explains a lot. Also, nothing other than "string" works as a type for @props() and I think this is why.
Not everyone comes from React especially people that use Ionic (and Angular).

Also, I found this Stencil Style Guide and there are "4. Internal props (context and connect)" and "11. hostData() function" sections that are not documented I think, because I cannot understand what they are.

@jgw96
Copy link
Contributor Author

jgw96 commented Jan 9, 2018

From @jthoms1 on January 9, 2018 14:14

For me this is definitely a documentation issue. I think that we need to create more examples on the website of how to accomplish these things JSX vs HTML etc. Does this sound right to everyone?

@jgw96
Copy link
Contributor Author

jgw96 commented Jan 9, 2018

I tend to agree with Josh here that this is a documentation issue. I can add this, probably to this section https://stenciljs.com/docs/templating. If everyone is in agreement that this is a docs issue then I will move this issue over to the stencil site repo.

@jgw96
Copy link
Contributor Author

jgw96 commented Jan 9, 2018

From @matteobortolazzo on January 9, 2018 14:38

Yes thanks, it's a documentation issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant