teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

4

修正

2020/03/11 09:34

投稿

sheckwes
sheckwes

スコア13

title CHANGED
File without changes
body CHANGED
@@ -82,6 +82,7 @@
82
82
 
83
83
  fetchData() {
84
84
  のところのコードがおかしいと思うのですが、原因がわかっていません。
85
+
85
86
  ---
86
87
  ###補足
87
88
  itemsのドキュメントにはphraseとurlというフィールドがあります。

3

詳細な情報の追加

2020/03/11 09:33

投稿

sheckwes
sheckwes

スコア13

title CHANGED
File without changes
body CHANGED
@@ -77,9 +77,11 @@
77
77
  ```
78
78
  ###現在出ているエラー
79
79
  ページを引っ張って更新しようとすると
80
- ReferenceError:Can't find variable:fetchData
80
+ TypeError:undefined is not an object(evaluating 'this.fetchData().then')
81
81
  と出ます。
82
82
 
83
+ fetchData() {
84
+ のところのコードがおかしいと思うのですが、原因がわかっていません。
83
85
  ---
84
86
  ###補足
85
87
  itemsのドキュメントにはphraseとurlというフィールドがあります。

2

修正

2020/03/11 09:31

投稿

sheckwes
sheckwes

スコア13

title CHANGED
File without changes
body CHANGED
@@ -14,22 +14,22 @@
14
14
  }
15
15
 
16
16
  fetchData() {
17
- const querySnapshot = Fire
17
+ const items = [];
18
+ Fire
18
19
  .shared
19
20
  .itemsCollection
20
21
  .get()
21
-
22
- const items = [];
22
+ .then(function(querySnapshot) {
23
- querySnapshot.forEach(doc => {
23
+ querySnapshot.forEach(function(doc) {
24
- items.push(doc.data());
24
+ items.push(doc.data());
25
- });
25
+ });
26
-
27
- this.setState({ items: items, refreshing:false });
26
+ this.setState({ items: items });
27
+ });
28
28
  }
29
29
 
30
30
  _onRefresh() {
31
31
  this.setState({refreshing: true});
32
- fetchData().then(() => {
32
+ this.fetchData().then(() => {
33
33
  this.setState({refreshing: false});
34
34
  });
35
35
  }

1

修正

2020/03/11 09:25

投稿

sheckwes
sheckwes

スコア13

title CHANGED
File without changes
body CHANGED
@@ -52,7 +52,6 @@
52
52
  const items = this.state.items;
53
53
  return (
54
54
  <Container>
55
-
56
55
  <Content style={styles.cnt} refreshControl={
57
56
  <RefreshControl
58
57
  refreshing={this.state.refreshing}