Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs 如何获取变量columnID_Reactjs - Fatal编程技术网

Reactjs 如何获取变量columnID

Reactjs 如何获取变量columnID,reactjs,Reactjs,我已经创建了删除按钮 我想获得column变量,以便能够删除正确列中的项,但我不知道如何获得该数据…我曾想过将数据作为道具传递给函数,但它不起作用 非常感谢你们的帮助 链接代码沙盒: 函数项({provided,Item,style,isDraging,column}){ 返回( {item.text} console.log(“column”,column)}>Delete ); 而不是传递列。在itemDataprop中的items可以传递列。现在,您可以通过数据道具访问行组件中的列数据

我已经创建了删除按钮

我想获得column变量,以便能够删除正确列中的项,但我不知道如何获得该数据…我曾想过将数据作为道具传递给函数,但它不起作用

非常感谢你们的帮助

链接代码沙盒:

函数项({provided,Item,style,isDraging,column}){
返回(
{item.text}
console.log(“column”,column)}>Delete
);

而不是传递
列。在
itemData
prop中的items
可以传递
。现在,您可以通过
数据
道具访问
组件中的
数据,然后将该道具传递到
项目
组件

<FixedSizeList {...props} itemData={column}>
  {Row}
</FixedSizeList>

{Row}
const行=React.memo(功能行(道具){
const{data:column,index,style}=props
常量{items}=列
常量项=项[索引]
如果(!项){
返回空
}
返回(
{(已提供)=>(
)}
)
},他们是平等的)

非常感谢,我非常感谢您的帮助。诚挚的问候。@JGPcode不客气。很乐意帮忙。
<FixedSizeList {...props} itemData={column}>
  {Row}
</FixedSizeList>
const Row = React.memo(function Row(props) {
  const { data: column, index, style } = props
  const { items } = column
  const item = items[index]
  if (!item) {
    return null
  }

  return (
    <Draggable draggableId={item.id} index={index} key={item.id}>
      {(provided) => (
        <Item provided={provided} item={item} style={style} column={column} />
      )}
    </Draggable>
  )
}, areEqual)