Created
August 14, 2018 13:46
-
-
Save maecapozzi/b701dd053cb34246575b8656c700a7dc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Grandmother extends React.Component { | |
state = { | |
lastName: 'Sanchez' | |
} | |
// When this function is called, the | |
// Grandmother's last name is updated | |
immigrateTo = (country, newLastName) => { | |
this.setState({ lastName: newLastName }) | |
} | |
componentDidMount() { | |
this.immigrateTo('US', 'Smith') | |
} | |
render () { | |
// Even though the Grandmother's last name | |
// was Sanchez, once her name is changed, | |
// the Mother inherits the name "Smith." | |
<Mother lastName={this.state.lastName} /> | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment