Reputation: 1
I am new to react and following a tutorial https://facebook.github.io/react/docs/components-and-props.html
I have the code below. I don't understand why won't it render the contents.
function Welcome(props) {
return <h1>Hello, {props.surname}</h1>;
}
function App(props) {
return (
<div>
<Welcome surname = {props.surname} />
<Welcome surname = {props.surname} />
<Welcome surname = {props.surname} />
</div>
);
}
function myApp(){
return (
<div>
<App surname = "Simon" />
</div>
);
}
ReactDOM.render(
<myApp/>,
document.getElementById('root')
);
I am following the similar example this one: https://codepen.io/gaearon/pen/KgQKPr?editors=0010
The only thing I did different was to add a different component on top and changed the props data.
Please let me know if I am missing on anything.
Upvotes: 0
Views: 43
Reputation: 16482
The first letter of react component should be capital. So convert your myApp
to MyApp
function MyApp(){
return (
<div>
<App surname = "Simon" />
</div>
);
}
ReactDOM.render(
<MyApp/>,
document.getElementById('root')
);
Upvotes: 3