-
Notifications
You must be signed in to change notification settings - Fork 0
/
apptem
executable file
·111 lines (73 loc) · 2.73 KB
/
apptem
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
const App = () => {
const [ list, setList ] = useState([]);
const [ input, setInput ] = useState('');
const [ inputEdit, setInputEdit ] = useState('');
const [ inputbox, setInputbox ] = useState('');
const onChange = e => {
setInput(e.target.value);
};
const onChangeEdit = (e) => {
setInputEdit(e.target.value);
};
const onInsert = e => {
const nextList = list.concat(input);
setList(nextList);
setInput('');
};
const onRemove = (value, index) => {
setList(list.filter((_,i) => i !== index))
}
const onEdit = (value, index, inputEdit) =>{
console.log(inputEdit)
list[index]=inputEdit
setList(list)
setInputEdit('')
}
return (
<div>
<input value={input} onChange={onChange} />
<button onClick={onInsert}>Add</button>
<input value={inputEdit} onChange={ e => onChangeEdit(e) }/>
<ul>
{list.map((value, index) => (
<li key={index}>
{value}
<button type="button"
onClick={() => onRemove(value, index)}
>
Remove
</button>
<button type="button"
onClick={() => onEdit(value, index, inputEdit)}
>
Edit
</button>
</li>
))}
</ul>
</div>
);
};
export default App;
4asfafsaf
1251
{/* <input value={inputReply} onChange={onChangeReply} />
<button onClick={onInsertReply(index)}>Reply</button>
{listReply.map((valueReply, indexReply) => (
<div key={indexReply}>
{valueReply}
</div>
))} */}
{/*
<button type="button"
onClick={() => onRemove(value, index)}
>
Remove
</button>
<button type="button"
onClick={() => onEdit(value, index, inputEdit,inputbox)}
>
Edit
</button>
<input value={inputbox[index]} onChange={ e => onChangeEdit(e,index)} id={index}/>
*/}