MCPcopy Create free account
hub / github.com/Klerith/react-hooks / CounterApp

Function CounterApp

src/01-useState/CounterApp.jsx:3–32  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1import { useState } from 'react';
2
3export const CounterApp = () => {
4
5 const [ state, setCounter] = useState({
6 counter1: 10,
7 counter2: 20,
8 counter3: 30,
9 });
10
11 const { counter1, counter2, counter3 } = state;
12
13 return (
14 <>
15 <h1>Counter1: { counter1 }</h1>
16 <h1>Counter2: { counter2 }</h1>
17 <h1>Counter3: { counter3 }</h1>
18
19 <hr />
20
21 <button
22 className="btn"
23 onClick={
24 () => setCounter({
25 ...state,
26 counter1: counter1 + 1,
27 })
28 }>+1</button>
29
30 </>
31 )
32}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected