Pass State as Props to Child Components-not sure what to do

Pass State as Props to Child Components-not sure what to do
0

#1

Tell us what’s happening:

I can only past the first requirment.

Your code so far


class MyApp extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      name: 'CamperBot'
    }
  }
  render() {
    return (
       <div>
         <Navbar MyApp={this.state.name}/>
       </div>
    );
  }
};

class Navbar extends React.Component {
  constructor(props) {
    super(props);
  }
  render() {
    return (
    <div>
      <h1>Hello, my name is: {this.props.name} </h1>
    </div>
    );
  }
};

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/front-end-libraries/react/pass-state-as-props-to-child-components


#2

The Navbar class is trying to render the name property on its props object:

this.props.name

However, in the MyApp class, you never passed a name property to Navbar. Instead, you passed a MyApp property.


#3

Thanks! should be name ={this.state.name}