cant seem to understand what to do in the below challenge
can someone help?
https://learn.freecodecamp.org/front-end-libraries/react/pass-state-as-props-to-child-components
cant seem to understand what to do in the below challenge
can someone help?
https://learn.freecodecamp.org/front-end-libraries/react/pass-state-as-props-to-child-components
Just as you can pass regular values as props, you can also grab data from a component’s state and pass it down as props for any of its child components.
class SomeParentComponent extends React.Component {
constructor(props) {
super(props);
this.state = {color: 'red'};
}
render() {
return <SomeChildComponent color={this.state.color} />;
}
}
Thankyou
yes i passed that data from component state to navbar
but can’t seem to figure out what comes in <h1>
tag
The value for that part comes from that component’s props. Continuing with the example code above, this is how the child component might use the data it received from the parent’s state:
class SomeChileComponent extends React.Component {
render() {
return <p>My favorite color is {this.props.color}.</p>;
}
}
Thank you
i cleared that
thanks for clearing that up
Really appreciate your help