質問編集履歴
1
実装したい内容に対してサンプルが間違っていたので修正しました。
title
CHANGED
File without changes
|
body
CHANGED
@@ -8,20 +8,18 @@
|
|
8
8
|
下記の場合は非同期で処理するので
|
9
9
|
Hogeコンポーネントへの引数が初期化されない値と判定されます。
|
10
10
|
```React
|
11
|
-
import
|
11
|
+
import { Hoge } from './components/Hoge';
|
12
12
|
|
13
|
+
let strAry: string[];
|
14
|
+
axios.post<string[]>("http://localhost:8080/", null, undefined).then((res) => {
|
15
|
+
strAry = res.data;
|
16
|
+
});
|
17
|
+
|
13
18
|
function App() {
|
14
|
-
|
15
|
-
let strAry: string[];
|
16
|
-
axios.post<string[]>("http://localhost:8080/", null, undefined).then((res) => {
|
17
|
-
strAry = res.data;
|
18
|
-
});
|
19
|
-
|
20
19
|
return (
|
21
20
|
<div>
|
22
21
|
<Hoge strAry={strAry} />
|
23
22
|
</div>
|
24
|
-
|
25
23
|
);
|
26
24
|
}
|
27
25
|
|