this
keyword. To access props within a class component, you preface the code that you use to access it with this
. For example, if an ES6 class component has a prop called data
, you write {this.props.data}
in JSX.
ReturnTempPassword
component in the parent component ResetPassword
. Here, give ReturnTempPassword
a prop of tempPassword
and assign it a value of a string that is at least 8 characters long. Within the child, ReturnTempPassword
, access the tempPassword
prop within the strong
tags to make sure the user sees the temporary password.
ResetPassword
component should return a single div
element.
testString: 'assert((function() { const mockedComponent = Enzyme.mount(React.createElement(ResetPassword)); return mockedComponent.children().type() === "div"; })(), "The ResetPassword
component should return a single div
element.");'
- text: The fourth child of ResetPassword
should be the ReturnTempPassword
component.
testString: 'assert((function() { const mockedComponent = Enzyme.mount(React.createElement(ResetPassword)); return mockedComponent.children().childAt(3).name() === "ReturnTempPassword"; })(), "The fourth child of ResetPassword
should be the ReturnTempPassword
component.");'
- text: The ReturnTempPassword
component should have a prop called tempPassword
.
testString: 'assert((function() { const mockedComponent = Enzyme.mount(React.createElement(ResetPassword)); return mockedComponent.find("ReturnTempPassword").props().tempPassword; })(), "The ReturnTempPassword
component should have a prop called tempPassword
.");'
- text: The tempPassword
prop of ReturnTempPassword
should be equal to a string of at least 8
characters.
testString: 'assert((function() { const mockedComponent = Enzyme.mount(React.createElement(ResetPassword)); const temp = mockedComponent.find("ReturnTempPassword").props().tempPassword; return typeof temp === "string" && temp.length >= 8; })(), "The tempPassword
prop of ReturnTempPassword
should be equal to a string of at least 8
characters.");'
- text: The ReturnTempPassword
component should display the password you create as the tempPassword
prop within strong
tags.
testString: 'assert((function() { const mockedComponent = Enzyme.mount(React.createElement(ResetPassword)); return mockedComponent.find("strong").text() === mockedComponent.find("ReturnTempPassword").props().tempPassword; })(), "The ReturnTempPassword
component should display the password you create as the tempPassword
prop within strong
tags.");'
```
Your temporary password is:
{ /* change code above this line */ }Your temporary password is: {this.props.tempPassword}