Access Props Using this.props

Access Props Using this.props
0.0 0

#1

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


#2

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


#3

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


#4

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 */ }

);
}
};