Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
52
rated 0 times [  55] [ 3]  / answers: 1 / hits: 41810  / 9 Years ago, fri, april 24, 2015, 12:00:00

I have created a simple React component which displays another react component. But it doesn't render in browser :



class Home extends React.Component {
render() {
return (
<div>
<map/>
</div>
);
}
}

var map = React.createClass({
render: function() {
return (
<div id=map-canvas>
<span>hello</span>
</div>
);
}
});


I'm expecting the hello to show up on the screen, but nothing shows up and when I inspect the element all I can see is



<map data-reactid=.0.0></map>


Can any one point our what might be wrong.


More From » reactjs

 Answers
10

JSX expects component tags to be capitalized. Otherwise, it will just create a DOM element with the provided tag. See HTML Tags vs. React Components.



<map /> compiles to React.createElement(map, {}); while <Map /> compiles to React.createElement(Map, {});.



Just rename map to Map and you're good.


[#66910] Thursday, April 23, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
payne

Total Points: 527
Total Questions: 108
Total Answers: 88

Location: Tajikistan
Member since Thu, Apr 14, 2022
2 Years ago
;