()
| 1 | import { useState } from 'react'; |
| 2 | |
| 3 | export 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 | } |
nothing calls this directly
no outgoing calls
no test coverage detected