Created
February 6, 2019 09:49
-
-
Save gisderdube/a682d50322be2b5617f2a59c8c5ba41b to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| 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