Access Props Using this.props (Not working)

Tell us what’s happening:
It’s not working
Describe your issue in detail here.

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

        { /* 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/91.0.4472.77 Safari/537.36

Challenge: Access Props Using this.props

Link to the challenge:

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 */ }
//You need to render ReturnTempPassword component in this line 
        { /* Change code above this line */ }
      </div>
  );
}

Hello @n6chernin , you have to render ReturnTempPassword as a component inside ResetPassword and give it a prop of tempPassword if you want to use that property the way you have. Something like below.

[quote=“n6chernin, post:1, topic:463784”]

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=“stringOfAtleast8Characters”/>
        { /* Change code above this line */ }
      </div>
  );
}
};

After doing that, your solution should work now.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.