summaryrefslogtreecommitdiff
path: root/examples/framework-multiple/src/components/ReactCounter.jsx
blob: cdd42bee27b20a56a2015ad66d76609bd511de29 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import { useState } from 'react';

/** a counter written in React */
export function Counter({ children }) {
	const [count, setCount] = useState(0);
	const add = () => setCount((i) => i + 1);
	const subtract = () => setCount((i) => i - 1);

	return (
		<>
			<div className="counter">
				<button onClick={subtract}>-</button>
				<pre>{count}</pre>
				<button onClick={add}>+</button>
			</div>
			<div className="counter-message">{children}</div>
		</>
	);
}
9c7?s=13&d=retro' width='13' height='13' alt='Gravatar' /> Fred K. Schott 2-5/+5 2021-11-18Update yarn.lock to reflect the state of the package.json files (#1892)Gravatar Jonathan Neal 5-1300/+1000 * update dependencies * update file to fix build:all 2021-11-19[ci] yarn formatGravatar FredKSchott 1-5/+3