Sunday, May 12, 2024
 Popular · Latest · Hot · Upcoming
70
rated 0 times [  75] [ 5]  / answers: 1 / hits: 78926  / 9 Years ago, thu, may 21, 2015, 12:00:00

I am playing around with the ReactJS framework on JSBin.



I have noticed that if my component name starts with a lowercase letter it does not work.



For instance the following does not render:



var fml = React.createClass({
render: function () {
return <a href='google.com'>Go</a>
}
});

React.render(<fml />, document.body);


But as soon as I replace the fml with Fml it does render.



Is there a reason I cannot begin tags with small letters?


More From » reactjs

 Answers
4

In JSX, lower-case tag names are considered to be HTML tags. However, lower-case tag names with a dot (property accessor) aren't.



See HTML tags vs React Components.




  • <component /> compiles to React.createElement('component') (html tag)

  • <Component /> compiles to React.createElement(Component)

  • <obj.component /> compiles to React.createElement(obj.component)


[#66511] Tuesday, May 19, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
rocioblancac

Total Points: 699
Total Questions: 96
Total Answers: 108

Location: Libya
Member since Mon, Dec 7, 2020
4 Years ago
;