Pass State as Props to Child Components-

Pass State as Props to Child Components-
0

#1

Tell us what’s happening:
I need help.

Your code so far


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

class Navbar extends React.Component {
  constructor(props) {
    super(props);
  }
  render() {
    return (
    <div>
      <h1>Hello, my name is: /* your code here */ </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

You can access state like so:

this.state.variableName

To get props:

this.props.name

I recommend reading this :wink:


#3

I read it but it isn’t clear to me.How can I understand it?


#4

Maybe you should point out at which part you have problems understanding it? Otherwise it’s a bit complicated to give an answer.


#5

I don’t understand what to write in your code here in my code.