问题
When I set isDragDisabled to true (hard coded) I am getting an error like this
index.js:1446 raw Error: Invariant failed:
Cannot find drag handle element inside of Draggable.
Please be sure to apply the {...provided.dragHandleProps} to your Draggable
My draggable component is
class Task extends Component {
render() {
console.log("taskID: ", this.props.task.id, this.props.task.id === 1)
return (
<Draggable
draggableId={this.props.task.id}
index={this.props.index}
isDragDisabled={true}
>
{
(provided, snapshot) => {
// console.log("SN:DRAGBLE:TASK: ", snapshot)
return <Container
{...provided.draggableProps}
{...provided.dragHandleProps}
ref={provided.innerRef}
isDragging={snapshot.isDragging}
>
{`
${this.props.task.id} :
${this.props.task.content}
`}
</Container>
}
}
</Draggable>
);
}
}
and droppable is :
class Column extends Component {
render() {
return (
<Container>
<Title>{`${this.props.column.title}: ${this.props.column.id}`}</Title>
<Droppable droppableId={this.props.column.id}>
{
(provided, snapshot) => {
// console.log("SN:DRPABLE:CLMN: ", snapshot)
return <TaskList
ref={provided.innerRef}
{...provided.droppableProps}
isDragging={snapshot.isDraggingOver}
>
{
this.props.tasks.map((task, index) => <Task key={index} task={task} index={index}/>)
}
{provided.placeholder}
</TaskList>
}
}
</Droppable>
</Container>
);
}
}
You can find the code sandbox https://codesandbox.io/embed/github/softmantk/react-dnd-example/tree/test-drag-disable/
if isDragDisabled
prop is removed from the file components/task.js, it will run fine.
回答1:
Changing the version of react-beautiful-dnd from 11.0.0-beta to 10.1.1 will fix this problem.
I created a github issue for this: https://github.com/atlassian/react-beautiful-dnd/issues/1224
回答2:
This has been fixed in 11.0.0-beta.2
. Upgrading to that version will fix your issue
来源:https://stackoverflow.com/questions/55556640/getting-error-find-drag-handle-element-inside-of-draggable-when-adding-isdragd