Access Props Using this.props

Tell us what’s happening:
I’m accessing the prop tempPassword within the component but the tests are failing, i’m not sure what i’m doing wrong

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= {"12345678"}/>
          { /* change code above this line */ }
        </div>
    );
  }
};

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/front-end-libraries/react/access-props-using-this-props

I think you don’t need the { } around the string “12345678” to pass it as tempPassword property.

1 Like

Thank you!
the {} was asked before for numbers, but for strings it looks like it’s fine

mine pass the test and its exactly like yours:

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

}
render() {
return (


{ /* 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 (


Reset Password


We’ve generated a new temporary password for you.


Please reset this password from your account settings ASAP.


{ /* change code below this line / }
<ReturnTempPassword tempPassword= {“12345678”}/>
{ /
change code above this line */ }

);
}
};

Please someone tell me what is wrong with my code… thanks
class ReturnTempPassword extends React.Component {
constructor(props) {
super(props);

}
render() {
return (

Your temporary password is: (this.props.tempPassword)

    </div>
);

}
};

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

}
render() {
return (


Reset Password


We’ve generated a new temporary password for you.


Please reset this password from your account settings ASAP.


{ /* change code below this line / }
<ReturnTempPassword tempPassword= {“12345678”} />
{ /
change code above this line */ }

);
}
};

Try clearing out your original answer and rewriting your work in the original problem - worked 2nd time for me.

I think it has something to do with the whitespaces.

Yes dhahn1 his right, some problem with

<p>Your temporary password is: <strong> {this.props.tempPassword}</strong></p>

Change it with

<p>Your temporary password is: <strong>{this.props.tempPassword}</strong></p>

1 Like

I don’t know if you are still dealing with this problem, but I notice you have a close div </div>, but not an open div <div>.

Also, when you post code, please highlight the code and click the “Preformatted text” button. It looks like two angle brackets with a slash between them. This will make your code display as you typed it.

1 Like