回答編集履歴
2
こっちの方がいいかな
test
CHANGED
@@ -40,25 +40,21 @@
|
|
40
40
|
|
41
41
|
const [val, setVal] = React.useState("");
|
42
42
|
|
43
|
-
const
|
43
|
+
const getVal = (e) => {
|
44
44
|
|
45
|
-
|
45
|
+
let val = ""
|
46
46
|
|
47
|
-
|
47
|
+
if(e.indexOf('dog') !== -1){
|
48
48
|
|
49
|
-
//ここでdogを含むかチェック
|
50
|
-
|
51
|
-
if(val.indexOf('dog') !== -1){
|
52
|
-
|
53
|
-
|
49
|
+
val = "犬派です"
|
54
50
|
|
55
51
|
}else if(e.indexOf('cat') !== -1){
|
56
52
|
|
57
|
-
|
53
|
+
val = "猫派です"
|
58
54
|
|
59
55
|
}
|
60
56
|
|
61
|
-
set
|
57
|
+
setVal(val)
|
62
58
|
|
63
59
|
};
|
64
60
|
|
@@ -112,7 +108,7 @@
|
|
112
108
|
|
113
109
|
</label>
|
114
110
|
|
115
|
-
<p>{
|
111
|
+
<p>{val}</p>
|
116
112
|
|
117
113
|
</>
|
118
114
|
|
1
consoleはいらない
test
CHANGED
@@ -57,8 +57,6 @@
|
|
57
57
|
result = "猫派です"
|
58
58
|
|
59
59
|
}
|
60
|
-
|
61
|
-
console.log("R"+result)
|
62
60
|
|
63
61
|
setResult(result)
|
64
62
|
|