質問編集履歴
3
FormSlectコンポーネントのコードの追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -21,10 +21,31 @@
|
|
21
21
|
|
22
22
|
export default SelectList;
|
23
23
|
```
|
24
|
+
```TypeScript
|
25
|
+
// Components > Form.tsx
|
26
|
+
export function FormSelect(props: any) {
|
27
|
+
let classNames = 'form-control ';
|
28
|
+
if (props.className !== undefined){
|
29
|
+
classNames += props.className;
|
30
|
+
}
|
31
|
+
|
32
|
+
return (
|
33
|
+
<select {...props} className={classNames}>
|
34
|
+
<option hidden>{props.hiddenlabel}</option>
|
35
|
+
{props.options?.map((option: string, index: number) => {
|
36
|
+
return <option value={index+1} key={index}>{option}</option>
|
37
|
+
})}
|
38
|
+
</select>
|
39
|
+
)
|
40
|
+
}
|
41
|
+
|
42
|
+
export default {};
|
43
|
+
```
|
24
44
|
|
25
45
|
```TypeScript
|
26
46
|
import React, { useState } from 'react';
|
27
47
|
import { Link } from 'react-router-dom';
|
48
|
+
import { FormSelect } from '../Components';
|
28
49
|
|
29
50
|
function ContactNew(props: any) {
|
30
51
|
function handleContactNew() {
|
2
コード修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -54,6 +54,7 @@
|
|
54
54
|
|
55
55
|
return (
|
56
56
|
<>
|
57
|
+
// 略 nickname, email, content入力欄は省略
|
57
58
|
<FormSelect className='select' style={{ marginBottom: "20px"}} id="selection" name="selection" type='selectbox'
|
58
59
|
hiddenlabel='選択してください'
|
59
60
|
options={SelectList.list.map((option, key) => (
|
1
誤字修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
Reactで
|
1
|
+
Reactでドロップダウン選択を実装しています。
|
2
2
|
|
3
3
|
console.log(formData)でオブジェクトの中身を出力すると、
|
4
4
|
selectionの値が数値になっています。
|
5
|
-
|
5
|
+
画像は、'お問い合わせ内容3'を選択したパターンです。
|
6
6
|
こちらをlabelプロパティの'お問い合わせ内容1'のように出力させるようにしたいです。
|
7
7
|
そもそもなぜ数値が出力されるのかが不明でして、ご教示いただければと思います。
|
8
8
|
|