Skip to content

Instantly share code, notes, and snippets.

@fredbegin11
Created February 9, 2019 03:28
Show Gist options
  • Select an option

  • Save fredbegin11/0b4f9ecdee92249c17406deb51dc899e to your computer and use it in GitHub Desktop.

Select an option

Save fredbegin11/0b4f9ecdee92249c17406deb51dc899e to your computer and use it in GitHub Desktop.
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