Two questions about this challenge.
Q1: Why can’t we use "this.state.name’ instead of “this.props.name”?
Q2:Where does the output come from? Is it rendered by MyApp or Navbar as both of then have render part. Thanks!
**Your code so far**
class MyApp extends React.Component {
constructor(props) {
super(props);
this.state = {
name: 'CamperBot'
}
}
render() {
return (
<div>
{/* Change code below this line */}
<Navbar name = {this.state.name}/>
{/* Change code above this line */}
</div>
);
}
};
class Navbar extends React.Component {
constructor(props) {
super(props);
}
render() {
return (
<div>
{/* Change code below this line */}
<h1>Hello, my name is: {this.props.name}</h1>
{/* Change code above this line */}
</div>
);
}
};
console.log(MyApp)
**Your browser information:**
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36
Challenge: Pass State as Props to Child Components
Link to the challenge: