king77
October 9, 2019, 2:17pm
1
Tell us what’s happening:
Your code so far
class MyComponent extends React.Component {
constructor(props) {
super(props);
this.state = {
name: 'freeCodeCamp'
}
}
render() {
// change code below this line
// change code above this line
return (
<div>
{ /* change code below this line */ }
<h1> {name} </h1>
{ /* change code above this line */ }
</div>
);
}
};
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:69.0) Gecko/20100101 Firefox/69.0
.
Link to the challenge:
Learn to code. Build projects. Earn certifications.Since 2015, 40,000 graduates have gotten jobs at tech companies including Google, Apple, Amazon, and Microsoft.
what is your question? what have you tried?
king77
October 9, 2019, 2:26pm
5
Whats wrong with my code below…?
class MyComponent extends React.Component {
constructor(props) {
super(props);
this.state = {
name: ‘freeCodeCamp’
}
}
render() {
// change code below this line
// change code above this line
return (
<div>
{ /* change code below this line */ }
<h1> {name} </h1>
{ /* change code above this line */ }
</div>
);
}
};
you also need to change the other line.
the h1 tags and name are fine
a hint they gave:
Remember that how you can access the property of a state.
i am having the same problem,which other line i’m i supposed to change after adding the <h1> {name} </h1>
.
it keeps telling me this below…
he rendered h1
header should contain text rendered from the component’s state.
You need to access the state object in that component, there isn’t a variable called name
anywhere on your code, you need that and you need its value to be the value of the name property in the state
It finally worked. I didnt know why it was not working before as I was doing everything correctly!!
1 Like