0

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.

1 Answer 1

3

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')
);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.