Skip to content

Instantly share code, notes, and snippets.

@Jahans3
Created December 1, 2018 01:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Jahans3/1a1aa337c63fc288fda2231ce8baf1d0 to your computer and use it in GitHub Desktop.
Save Jahans3/1a1aa337c63fc288fda2231ce8baf1d0 to your computer and use it in GitHub Desktop.
Use state
import React, { useState } from 'react';
function Counter () {
const [count, setCount] = useState(0);
return (
<>
<span>
Count: {count}
</span>
<button onClick={() => setCount(count + 1)}>
Increment
</button>
</>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment