FAQ: this.props - Render a Component's props

This community-built FAQ covers the “Render a Component’s props” exercise from the lesson “this.props”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Web Development

Learn ReactJS: Part I

FAQs on the exercise Render a Component’s props

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!


Regarding: Render a Component’s props

I am not getting the idea where it can be used or will help in real example. can someone please explin me in simple way please.


What am I supposed to be learning from writing the reactdom line in every single excercise? is it so hard to pre place it on the excercises?

I think the point of this exercise was to show the string interpolation use like when you have something like this:

var cat =‘meow’
var string = The cat says ${cat};

I think they are showing that usage but with this/JSX/React stuff… Though I will say step two which was write a new name to pass the exercise felt like busy work and not really pushing the concept further. This unit overall might need a bit of a tweak.

there should be back ticks before the dollar sign and then after the closing curly brace but for some reason didn’t show

The backticks don’t show because they are used in Markdown to denote inline code blocks, similar to using <code></code> tags in HTML.

In order to render the backticks they must be preceded by a backslash ( \ ). So in your example it could be written as so:
var string = The cat says `${cat}`;

An alternative is to use three backticks ( ``` ) before and after code to denote a code block:

var cat = 'meow';
var string = The cat says `${cat}`

Hope this helps clear it up a bit. Markdown can be very useful to easily add some basic formatting like lists, headings, quotes etc. I use it for taking notes as it allows me to format all my information like it is one large HTML document, without the cumbersome opening and closing tags.


in the following code, the define the first name (Groberta), after declaring the new react component which involves the first name. why isn’t there an error? why does this work? Is it because of hoisting?

import React from ‘react’;
import ReactDOM from ‘react-dom’;

class Greeting extends React.Component {
render() {

Hi there, {this.props.firstName}!



Hello, i have a question.
In this example:

const myFunction = (myNum) => {
return myNum +1;
let myVar = 1;

// ReferenceError: Cannot access ‘myVar’ before initialization

We get a reference error because the variable is called after console.log.

Why is the exercise example different?

The prop is declared AFTER the expression: {this.props.firstName}

Ok after 1 second i though myself the answer…its the ReactDOM.render which calls the class…so no inverted order :stuck_out_tongue: