Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

285
Visualizações
React Beautiful DND Invariant failed on draggable and droppable ids

Trying to figure out why I can't drag and drop my items (I get a hand over the list elements, but no ability to pick them up). I followed a tutorial to a T and i'm not sure why it's failing. I'm not concerned with list order or out of bounds dragging right now, just being able to drag at all.

I get the following errors:

A setup problem was encountered. > Invariant failed: Draggable requires a draggableId

A setup problem was encountered.> Invariant failed: A Droppable requires a droppableId prop

However, I believe I have all the necessary IDs on my elements. Here is my code (pls enjoy the sheRa references)

import React from "react";
import { DragDropContext, Droppable, Draggable } from "react-beautiful-dnd";

const sheRaCharacters = [
  {
    id: "Adora",
    name: "Adora",
    color: "#FFD700",
  },
  {
    id: "Catra",
    name: "Catra",
    color: "#ff0000",
  },
  {
    id: "Entrapta",
    name: "Entrapta",
    color: "purple",
  },
  {
    id: "Mermista",
    name: "Mermista",
    color: "#0000ff",
  },
];

class DragDropTest extends React.Component {

  render() {
    const listStyle = {
      backgroundColor: "pink",
      padding: "10px",
      margin: "8px",
      borderRadius: "8px",
    };

    const characterList = sheRaCharacters.map(({ id, name, color }, index) => {
      return (
        <Draggable key={id} draggableID={id} index={index}>
          {(provided) => (
            <li
              ref={provided.innerRef}
              {...provided.draggableProps}
              {...provided.dragHandleProps}
              style={listStyle}
            >
              <p style={{ color: color }}>{name}</p>
            </li>
          )}
        </Draggable>
      );
    });

    return (
      <div>
        <DragDropContext>
          <Droppable droppableID="characters">
            {(provided) => (
              <ul ref={provided.innerRef} {...provided.droppableProps}>
                {characterList}
                {provided.placeholder}
              </ul>
            )}
          </Droppable>
        </DragDropContext>
      </div>
    );
  }
}

export default DragDropTest;

So the droppable area has a string ID and all the draggable elements also have string IDs. What did I miss?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

JS is case sensitive so you must write 'draggableId' instead 'draggableID'

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda