Property names can be referenced as an attribute using kebab-case
See original GitHub issueFeature
When using attributes, kebab-case should be automatically recognized.
When I register a property to my Direflow Component:
App.defaultProps = {
componentTitle: "My Component Title"
}
I should be able to reference these as an attribute using kebab-case
<web-component component-title="New Title"></web-component>
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (5 by maintainers)
Top Results From Across the Web
Property and Attribute Names - Salesforce Developers
Property names in JavaScript are in camel case while HTML attribute names are in kebab case (dash-separated) to match HTML standards.
Read more >What is kebab case? - TheServerSide.com
Kebab case, or kebab-case, is a naming convention that allows a developer to create whitespace between words in code with a dash.
Read more >Allow for multiple naming conventions (camelCase vs kebab ...
Description json:api documentation recommends using camelCase instead of kebab case here and is discussed on json-api/json-api#1255.
Read more >lwc Kebab Case child component - Salesforce Stack Exchange
I'm not entirely sure that -case-name is a valid identifier. ... should be prefixed with hyphen(-) followed by the character in lowercase )....
Read more >Famous camelCase vs kebab-case JavaScript - Medium
HTML5 attributes can start with data- (data-name, data-price). CSS property names has a hyphen (font-size, background-color).
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@Silind,
Why is this closed and considered redundant? It seems that if I pass in a prop via an attribute that I need to use all lower case for my prop, for example:
App.defaultProps = { componenttitle: “My Component Title” }
<web-component componenttitle="New Title"></web-component>
So when componenttitle changes, my useEffect in my component gets the change. If my prop is componentTitle and I set the html attribute to componentTitle it reverts to all lowercase (as html is case insensitive), and my component doesn’t get the changed value.
I’m using the latest 3.5.0 version. Is there a way for me to use camelCase prop and have it update using an attribute in html?
I agree with this strategy, sounds fine.