Open History to see the last commit
1import { useState } from 'react'
2β
3import { createCounter } from './counter'
4β
5const counterInstance = createCounter()
6β
7export default function App() {
8 const [count, setCount] = useState(counterInstance.getCount())
9β
10 const increment = () => {
11 counterInstance.increment()
12 setCount(counterInstance.getCount())
13 }
14β
15 const decrement = () => {
16 counterInstance.decrement()
17 setCount(counterInstance.getCount())
18 }
19β
20 return (
21 <div>
22 <h1>Custom plugins</h1>
23 <h2>Count: {count}</h2>
24 <div style={{ display: 'flex', gap: '4px' }}>
25 <button onClick={increment}>+ increase</button>
26 <button onClick={decrement}>β decrease</button>
27 </div>
28 </div>
29 )
30}