Why do React components need to start with capital letters?
If you’ve ever worked with React, you might have noticed that component names always...
For further actions, you may consider blocking this person and/or reporting abuse
What about const SomeName = "some value" and projects without Babel?
SomeName
simply a variable, not a react component. Capitalization rule will not apply here, because its not being used as a react component here.Projects without babel, then React.createElement() Api is used Explicitly.
BTW, using Capital letters in Components, helps react to differentiate between
Native Elements and custom Components.
Eg.
If MyComponent is written in lower case (myComponent), React will look for a native HTML element
<myComponent>
which doesn't exists, causing the app to fail.I’m fairly sure for this they just check whether typeof input is string.
I see the point with createElement, but I still can write lower case functional component on a project without Babel and still get the error. So it's not Babel concern, as your article states
You're absolutely right! The capitalization rule in React isn't tied specifically to
Babel
, but rather to React itself. While Babel helps by converting JSX intoReact.createElement()
calls.This is not true either since React 17 jsx runtime
Short and informative thanks!
Thanks ❣️
That's good to know! Had always assumed it was just a matter of convention, although it would feel very strange to not capitalize a React component at this point :)
Thank you 👍
You are Welcome 😊
Ahhhha nice!
Thanks
Short and sweet!
Thanks
Fragile tech
Thanks
Good information, thanks for providing
Thanks ❣️
Thanks good to remember!
Thanks Man
Very good. Thank you!
Thank You ❣️
To the point and informative which clears the basic concept, thank you
Thanks man
Could you tell me cons of virtual dom in react js?
Thanks ❣️
New information, thank.❤️
Thanks ❣️
Concise and to the point. I love this!
Thanks Man ❣️
Thanks for the insight from the article and the informative comments. I've have learned and it's a good step to go and study more on the topic.
On a side note, Kotlin's Composable function components for Android, also start with a capital letter.