I am trying to use React Beautiful DND library to drag and drop lists in a todo application but I keep getting these three errors in my console.
Error 1:
Function components cannot be given refs. Attempts to access this ref will fail. Did you mean to use React.forwardRef()?
Check the render method of `Droppable`.
Error 2:
Function components cannot be given refs. Attempts to access this ref will fail. Did you mean to use React.forwardRef()?
Check the render method of `Draggable`.
Error 3:
Invariant failed: provided.innerRef has not been provided with a HTMLElement.
The following is a snippet of the my code. I also made use of styled components:
import React from 'react';
import styled from 'styled-components';
import { DragDropContext, Droppable, Draggable } from 'react-beautiful-dnd';
function App() {
...
return (
<>
<DragDropContext>
<Droppable>
{(provided) => (
<TodoList {...provided.droppableProps} ref={provided.innerRef}>
{
shadowTodoItems.map((todoItem, index) => (
<Draggable key={todoItem.id} draggableId={todoItem.id} index={index}>
{(provided) => (
<div>
<TodoListItem ref={provided.innerRef} {...provided.draggableProps} {...provided.dragHandleProps} />
</div>
)}
</Draggable>
))
}
{provided.placeholder}
</TodoList>
)}
</Droppable>
</DragDropContext>
</>
);
}
How do I fix these errors please? Thank you.