Last active
April 25, 2018 13:20
-
-
Save apalmer0/537120cb2a22b74697ad927dec621962 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 City extends Component { | |
state = { | |
active: false, | |
} | |
handleClick = () => ( | |
this.setState({ | |
active: !this.state.active, | |
}) | |
) | |
render() { | |
const { active } = this.state | |
const { name } = this.props | |
const color = active ? '#F00' : '#000' | |
const cityStyle = { color } | |
return ( | |
<div style={cityStyle} onClick={this.handleClick}> | |
{name} | |
</div> | |
) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment