Skip to content

Instantly share code, notes, and snippets.

@aabccd021
Created May 11, 2020 14:16
Show Gist options
  • Save aabccd021/b2c6ba117806d9490cea2445cf452e4e to your computer and use it in GitHub Desktop.
Save aabccd021/b2c6ba117806d9490cea2445cf452e4e to your computer and use it in GitHub Desktop.
import * as React from 'react';
const { useState } = React;
export const UseStateSample = () => {
const [count, setCount] = useState(0);
return (
<p>
<button onClick={() => setCount(count - 1)}>-</button>
<b>{count}</b>
<button onClick={() => setCount(count + 1)}>+</button>
</p>
);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment