Skip to content

Instantly share code, notes, and snippets.

@apalmer0
Last active April 25, 2018 13:20
Show Gist options
  • Save apalmer0/537120cb2a22b74697ad927dec621962 to your computer and use it in GitHub Desktop.
Save apalmer0/537120cb2a22b74697ad927dec621962 to your computer and use it in GitHub Desktop.
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