React Beautiful dnd 转换功能组件
React Beautiful dnd converting functional componentings
我正在尝试将 beautiful-dnd 转换为功能组件并将它们拆分为不同的组件,但我只是想知道为什么会抛出错误?
谢谢,
task.js
中出现问题。你忘了传播 provided.dragHandleProps
import React from 'react'
import { Draggable } from 'react-beautiful-dnd'
const Task = props => {
console.log(props)
return (
<Draggable draggableId={props.task.id} index={props.index}>
{(provided, snapshot) => (
<div
ref={provided.innerRef} // <-- this as well
{...provided.draggableProps}
{...provided.dragHandleProps} // <-- here
>
{props.task.content}
</div>
)}
</Draggable>
)
}
export default Task
我正在尝试将 beautiful-dnd 转换为功能组件并将它们拆分为不同的组件,但我只是想知道为什么会抛出错误?
谢谢,
task.js
中出现问题。你忘了传播 provided.dragHandleProps
import React from 'react'
import { Draggable } from 'react-beautiful-dnd'
const Task = props => {
console.log(props)
return (
<Draggable draggableId={props.task.id} index={props.index}>
{(provided, snapshot) => (
<div
ref={provided.innerRef} // <-- this as well
{...provided.draggableProps}
{...provided.dragHandleProps} // <-- here
>
{props.task.content}
</div>
)}
</Draggable>
)
}
export default Task