Access Props Using this.props help me in this problem

Access Props Using this.props help me in this problem
0.0 0

#1

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.tempPassowrd}</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 tempPassowrd = {"at least 8 characters"}/>
          { /* change code above this line */ }
        </div>
    );
  }
};

Your browser information:

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

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


#2

Hi Murtaza,

In ‘ResetPassword’ Component you are trying to render the ‘ReturnTempPassword’ Component as a child Component and then passing some static value in this case(whatever it may be) you have mentioned for tempPassword (for Example tempPassword ={1234567})… ‘tempPassword’ is then available as props in the Child Component i.e ‘ReturnTempPassword’, you can access the props value passed to the component by {this.props.tempPassword} its tempPassword in this case but it can be anything. yotu can call it ‘abc’ on the child component and it will be available as {this.props.abc} inside the child Component.

Hope this helped.

Good Luck.