Javascript ArrayField Formik动态反应

Javascript ArrayField Formik动态反应,javascript,arrays,reactjs,formik,Javascript,Arrays,Reactjs,Formik,我在寻找解决我问题的办法。 我想在formik中创建对象的嵌套数组,它将根据道具生成新的依赖组件。我的对象的动态捕捉路径有问题 表格的初始/示例正文: const后端={ 后端:“”, 计数:2, 筛选:[ { 路径:“”, 动词:[] } ], }; 我一直在尝试使用路径创建变量: const properPath = [`${values}${path}`] 但只有在硬编码路径时,它才能正常工作: values['filtering'][index]['verb'] 它工作正常 常

我在寻找解决我问题的办法。 我想在formik中创建对象的嵌套数组,它将根据道具生成新的依赖组件。我的对象的动态捕捉路径有问题

表格的初始/示例正文:

const后端={
后端:“”,
计数:2,
筛选:[
{
路径:“”,
动词:[]
}
],
};
我一直在尝试使用路径创建变量:

const properPath = [`${values}${path}`]
但只有在硬编码路径时,它才能正常工作:

values['filtering'][index]['verb'] 
它工作正常


常量数组形式=({path,filteringArrayProps,name,index})=>{
常量{values,setFieldValue}=useformicContext();
常量filt='filtering'
常量动词=`${values['filtering'][index]['verb']}`
常量properPath=[`${values}${path}`]
返回(
{properPath.map((项,index1)=>(
{index1>0&&(
filteringArrayProps.remove(index1)}>
去除
)}
))}
filteringArrayProps.push(“”)}>
添加
)
}
带有的主窗体应该传递路径,在该路径中我们应该添加新的对键值



constbackendform=()=>{
返回(
console.log('send')}>
{({values})=>(
{
console.log(
“姓名”,
event.target.name,
“|价值”,
event.target.value
);
}}
>
后端
统一资源定位地址
过滤
{fieldArrayProps=>{
const{push,remove,form}=fieldArrayProps
常量{values}=form
常量{筛选}=值
返回(
{筛选.map((身份验证,索引)=>(
路径
动词
{filteringArrayProps=>{
返回(
)
}}
{index>0&&(
删除(索引)}>
移除按钮
)}
))}
推送({path:,动词:[]})}>
添加按钮
)
}}
{JSON.stringify(值,null,2)}
)}
);
};