Render State in the User Interface and other challenges

Render State in the User Interface and other challenges
0

#1

This post is not specific to the following error that I received but in general; Why there are no answers to the challenges, how a beginner having difficulties running the challenges know where s/he went wrong? the creators of this site don’t expect the users to post every non-working challenge to the forum, do they?

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

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/front-end-libraries/react/render-state-in-the-user-interface


#2

You are suppose to read the challenge to try and understand the material. Next, if you have difficulty understanding the material, you should search the forum or your favorite search engine for help with anything you do not understand (i.e. terms), and if all else fails, ask a specific question on the forum. This is how FCC works.

So what part of the challenge instructions are you having trouble understanding?


#3

Well firstly, what is wrong with the above code?

And secondly, it is very convenient for learner to have sample answers provided for them as an option after number of failed tries.

Regards


#4

The above line in your code references the this.state object, but you need to reference the property name that is located in the this.state. That is why the instructions state:

Define an h1 tag in the component’s render method which renders the value of name from the component’s state.

this.state could have many properties, so you have to be specific about which one you want to display.

React is just JavaScript. Objects behave the same in React as they do in plain JavaScript. For example, let’s say I have the following object:

var obj = {
  name: 'Sammy',
  camper: true
}

If I want to access the name property in obj, I would not write:

obj

Instead, I would write:

obj.name

#5

Thank you very much for your prompt replays, I am really grateful for everyone involved in the FCC project, I just wanted to give a suggestion to improve the experience, I gather from your first reply that this forum is solely for question related to codes,
Thank you again and have a nice day.


#6

No, the forum is for discussing anything about the curriculum, the forum and of course coding. My reply was to explain how the curriculum is expected to be followed. It uses the Read, Search, Ask method.


#7

So the second part of my post was relevant, Why you left it off? Again I appreciate your help and you solved my issue but I know that asking for help in the programming world is a skill to be acquired so I follow up with this message.


#8

I am not sure what you mean. What did I leave off?


#9

“Why there are no answers to the challenges” like answer templates for reference provided in the curriculum, I think it will be very helpful


#10

The hints section is still being developed, so some of the challenges do not have extra information or solutions. The entire curriculum has been created by volunteers, so it takes time for all the hint sections to be written. I suspect the Guide will have most of the hint sections complete in the next couple of months.

In the mean time, you have the forum (which is made up of other campers and moderators (also volunteers) who can try to answer your questions.