質問編集履歴

2

itemの初期値を空文字列に変更

2022/02/16 08:49

投稿

hugahuga
hugahuga

スコア23

test CHANGED
File without changes
test CHANGED
@@ -19,7 +19,7 @@
19
19
  constructor(props) {
20
20
  super(props);
21
21
  this.state = {
22
- items: []
22
+ item: ''
23
23
  };
24
24
  }
25
25
  async componentDidMount() {
@@ -27,14 +27,14 @@
27
27
  const db = getFirestore();
28
28
  const docRef = doc(db, "", "");
29
29
  var docSnap = await getDoc(docRef);
30
- this.setState({items:docSnap.data()['0'][0]})
30
+ this.setState({item:docSnap.data()['0'][0]})
31
31
  }
32
32
  render() {
33
- const items = this.state.items;
33
+ const item = this.state.item;
34
34
  return (
35
35
  <div>
36
- <p>{items}</p>
36
+ <p>{item}</p>
37
- <TwitterTweetEmbed tweetId={{items}} options={{width:550}} />
37
+ <TwitterTweetEmbed tweetId={{item}} options={{width:550}} />
38
38
  </div>
39
39
  );
40
40
  };

1

該当のコンポーネントのID指定部分の文法がリファレンスと異なっていたため修正しました。挙動に変化はありませんでした。

2022/02/15 12:50

投稿

hugahuga
hugahuga

スコア23

test CHANGED
File without changes
test CHANGED
@@ -34,7 +34,7 @@
34
34
  return (
35
35
  <div>
36
36
  <p>{items}</p>
37
- <TwitterTweetEmbed tweetId={items} options={{width:550}} />
37
+ <TwitterTweetEmbed tweetId={{items}} options={{width:550}} />
38
38
  </div>
39
39
  );
40
40
  };