Skip to content

Instantly share code, notes, and snippets.

@gisderdube
Created February 6, 2019 09:49
Show Gist options
  • Select an option

  • Save gisderdube/a682d50322be2b5617f2a59c8c5ba41b to your computer and use it in GitHub Desktop.

Select an option

Save gisderdube/a682d50322be2b5617f2a59c8c5ba41b to your computer and use it in GitHub Desktop.
import React, { useState } from 'react'
function Counter() {
const [count, setCount] = useState(0)
const [color, setColor] = useState('#DC0073')
return (
<div>
<span style={{ color }}>Current count is: {count}</span>
<br />
<button onClick={() => setCount(count + 1)}>Increase count</button>
<button onClick={() => setColor(color === '#DC0073' ? '#00A1E4' : '#DC0073')}>
Change Color
</button>
</div>
)
}
export default Counter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment