Skip to content

Instantly share code, notes, and snippets.

@apalmer0
Last active April 25, 2018 13:20
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