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