Skip to content

Instantly share code, notes, and snippets.

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

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

Select an option

Save fredbegin11/e69c1ec052890efd9563578a1200daa9 to your computer and use it in GitHub Desktop.
Simple Counter using State Hook
import React, { useState } from 'react';
const Counter = () => {
const [count, setCount] = useState(0);
return (
<>
<p>Count: {count}</p>
<button onClick={() => setCount(count + 1)}>Increment</button>
<button onClick={() => setCount(count - 1)}>Decrement</button>
</>
);
};
export default Counter;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment