質問編集履歴
1
コードが抜けていた
test
CHANGED
File without changes
|
test
CHANGED
@@ -6,38 +6,104 @@
|
|
6
6
|
|
7
7
|
### 発生している問題・エラーメッセージ
|
8
8
|
|
9
|
-
ですが、現状if文の中ではconstにより
|
9
|
+
ですが、現状if文の中ではconstにより変数の定義がされていません。
|
10
10
|
|
11
|
-
|
11
|
+
if文内で定数を定義することは可能なのでしょうか?
|
12
12
|
|
13
|
-
エラーメッセージ
|
14
13
|
|
14
|
+
|
15
|
-
|
15
|
+
よろしくお願いします。
|
16
16
|
|
17
17
|
|
18
18
|
|
19
19
|
### 該当のソースコード
|
20
20
|
|
21
|
+
```JS
|
21
22
|
|
22
|
-
|
23
|
-
|
23
|
+
export default class ApplauseButton extends Component {
|
24
|
-
|
25
|
-
ソースコード
|
26
|
-
|
27
|
-
```
|
28
24
|
|
29
25
|
|
30
26
|
|
27
|
+
constructor(props) {
|
28
|
+
|
29
|
+
super(props);
|
30
|
+
|
31
|
+
this.state = {
|
32
|
+
|
31
|
-
|
33
|
+
count: 0,
|
34
|
+
|
35
|
+
applause: 100,
|
36
|
+
|
37
|
+
applauded: 0,
|
38
|
+
|
39
|
+
};
|
40
|
+
|
41
|
+
}
|
32
42
|
|
33
43
|
|
34
44
|
|
35
|
-
|
45
|
+
handlClick= async ()=> {
|
46
|
+
|
47
|
+
const {
|
48
|
+
|
49
|
+
mainuser,
|
50
|
+
|
51
|
+
subuser,
|
52
|
+
|
53
|
+
} = this.props;
|
36
54
|
|
37
55
|
|
38
56
|
|
39
|
-
|
57
|
+
if (mainuser === 'User1'){
|
58
|
+
|
59
|
+
const countapplauded = this.state.applauded + 1;
|
60
|
+
|
61
|
+
} else if (mainuser === 'User2') {
|
62
|
+
|
63
|
+
const countapplauded1 = this.state.applauded1 + 1;
|
64
|
+
|
65
|
+
}
|
66
|
+
|
67
|
+
};
|
40
68
|
|
41
69
|
|
42
70
|
|
71
|
+
render() {
|
72
|
+
|
73
|
+
const {
|
74
|
+
|
75
|
+
mainuser,
|
76
|
+
|
77
|
+
subuser,
|
78
|
+
|
79
|
+
} = this.props;
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
return (
|
84
|
+
|
85
|
+
<View style={styles.container}>
|
86
|
+
|
43
|
-
|
87
|
+
<TouchableHighlight
|
88
|
+
|
89
|
+
onPress={() => {this.handlClick()}}
|
90
|
+
|
91
|
+
onLongPress={this._onLongPressButton} underlayColor="white">
|
92
|
+
|
93
|
+
<View style={styles.button}>
|
94
|
+
|
95
|
+
<Text style={styles.buttonText}>????</Text>
|
96
|
+
|
97
|
+
</View>
|
98
|
+
|
99
|
+
</TouchableHighlight>
|
100
|
+
|
101
|
+
</View>
|
102
|
+
|
103
|
+
);
|
104
|
+
|
105
|
+
}
|
106
|
+
|
107
|
+
}
|
108
|
+
|
109
|
+
```
|