-
Notifications
You must be signed in to change notification settings - Fork 0
/
counter-result.js
59 lines (54 loc) · 1.34 KB
/
counter-result.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import { useSelector } from 'react-redux';
import Form from '@wishy-gift/noscript/dist/components/Form';
import Button from '@wishy-gift/noscript/dist/components/Button';
import {
decrement,
decrementByAmount,
increment,
incrementByAmount,
incrementBySurprise,
} from './counterSlice';
export default function Counter() {
const counter = useSelector((state) => state.counter.value);
return (
<div className="container">
<main className="main">
<h1 className="title">{`Counter: ${counter}`}</h1>
<div className="grid">
<Button className="btn" action={decrement()}>
-
</Button>
<Button className="btn" action={increment()}>
+
</Button>
</div>
<div className="grid">
<Form className="form" payloadType="json">
<button
className="btn"
name="actionType"
value={decrementByAmount().type}
>
- by amount
</button>
<label className="label">
<input className="input" name="payload" type="number" required />
</label>
<button
className="btn"
name="actionType"
value={incrementByAmount().type}
>
+ by amount
</button>
</Form>
</div>
<div className="grid">
<Button className="btn" actionCreator={incrementBySurprise}>
Surprise
</Button>
</div>
</main>
</div>
);
}