谁能给我指出在redux-form中迭代FieldArray的值的正确方向?我正在制作一个表单审查页面,我想在其中显示表单的所有值。我目前有一个名为customTrips的FieldArray,它看起来像这样:
"customTrips": [
{
"pick_up_date1": "2017-08-22",
"pick_up_time1": "12:31",
"airline1": "Delta",
"terminal1": "12",
"flight_Number": "213",
},
{
"pick_up_time1": "12:31",
"pick_up_date1": "2017-08-22",
"airline1": "American Airlines",
"terminal1": "5",
"flight_Number": "A12",
}
]这是我用来获取所有表单值的选择器:
const selector = getFormValues('wizard');
WizardFormEighthPage = connect(state => {
const formValues = selector(state);
return {
formValues
};
})(WizardFormEighthPage);我对如何遍历customTrips FieldArray并访问要在审查页面上显示的值感到困惑。任何帮助都将不胜感激。谢谢。
发布于 2017-08-23 04:05:23
我终于想通了!希望这篇文章能帮助任何面临类似问题的人。我能够使用getFormValues选择器并使用映射访问customTrips数组。这使我能够遍历customTrips数组。
下面是一个从customTrips FieldArray获取"pick_up_date1“值的示例:
{formValues.customTrips.map((customTrips, index) => (
<div id="trip1_itin" className="section" key={index}>
Address: {customTrips.pick_up_date1}
</div>
))}https://stackoverflow.com/questions/45824652
复制相似问题