Created
February 9, 2019 03:28
-
-
Save fredbegin11/0b4f9ecdee92249c17406deb51dc899e 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'; | |
| const MultiCounter = () => { | |
| const [age, setAge] = useState(26); | |
| const [months, setMonths] = useState(1); | |
| return ( | |
| <> | |
| <p>Age: {age}</p> | |
| <button onClick={() => setAge(age + 1)}>Increment Age</button> | |
| <button onClick={() => setAge(age - 1)}>Decrement Age</button> | |
| <p>Months: {months}</p> | |
| <button onClick={() => setMonths(months + 1)}>Increment Months</button> | |
| <button onClick={() => setMonths(months - 1)}>Decrement Months</button> | |
| </> | |
| ); | |
| }; | |
| export default MultiCounter; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment