Access Props Using this.props/ what the

Tell us what’s happening:

Your code so far


class ReturnTempPassword extends React.Component {
constructor(props) {
  super(props);

}
render() {
  return (
      <div>
          { /* change code below this line */ }
          <p>Your temporary password is: <strong>{this.props.tempPassword}</strong></p>
          { /* change code above this line */ }
      </div>
  );
}
};

class ResetPassword extends React.Component {
constructor(props) {
  super(props);

}
render() {
  return (
      <div>
        <h2>Reset Password</h2>
        <h3>We've generated a new temporary password for you.</h3>
        <h3>Please reset this password from your account settings ASAP.</h3>
        { /* change code below this line */ }
<ReturnTempPassword tempPassword = {Yikes22310} />
        { /* change code above this line */ }
      </div>
  );
}
};

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:76.0) Gecko/20100101 Firefox/76.0.

Challenge: Access Props Using this.props

Link to the challenge:

What is the matter? Did I accidentally delete something I shouldn’t have?

This line seems to be throwing your error. You are passing an object to the tempPassword when you should pass a string. :slight_smile:

Actually, it is not passing an object. It is trying to pass a variable named Yikes22310, but since there is no such variable, the value undefined is passed.

1 Like

Oops! :no_mouth: Thank you for the clarification! :smiley:

1 Like

Do they give me a variable that they want me to pass or do I have to make one?
Hello???

No, the instructions state it must be a string of 8 characters long:

Here, give ReturnTempPassword a prop of tempPassword and assign it a value of a string that is at least 8 characters long.

How do you pass a string as a prop?

I am going to take a quick break. This is really stressing me out. Which is probably silly…but that is me.

Tell us what’s happening:

Your code so far


class ReturnTempPassword extends React.Component {
constructor(props) {
  super(props);

}
render() {
  return (
      <div>
          { /* change code below this line */ }
          <p>Your temporary password is: <strong>{this.props.tempPassword}</strong></p>
         
          { /* change code above this line */ }
      </div>
  );
}
};

class ResetPassword extends React.Component {
constructor(props) {
  super(props);

}
render() {
  return (
      <div>
        <h2>Reset Password</h2>
        <h3>We've generated a new temporary password for you.</h3>
        <h3>Please reset this password from your account settings ASAP.</h3>
        { /* change code below this line */ }
<ReturnTempPassword tempPassword = {123456789} />
        { /* change code above this line */ }
      </div>
  );
}
};

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:76.0) Gecko/20100101 Firefox/76.0.

Now what’s wrong? i fixed it somewhat.

You seem to not understand the difference between a string and a number. How do you represent a string in JavaScript?

1 Like

“I am Dumb?” Is that a string in JS?

Literal strings are surrounded by quotes (single, double) or single backticks.

1 Like

I :crazy_face:got it! Thanks!