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

151
Visualizações
dropping a draggle block between an array of droppable elements not working correctly

I am working with react-dnd. What I am trying to achieve is dragging the block from the left and dropping it between already existing blocks. I have tried to replicate my issue in codesandbox. Link to which is here I am facing two issues here

First Issue:

As we continue to add blocks from the leftbar their is some issue and the blocks stop getting added to the rightbar. (To recreate the issue try adding couple of blocks to the rightbar, you can see it after adding 4 to 5 blocks).

code Reference:

after element is drop below function is called which i think where the exact issue is but not sure. You can find it in Dustbin.js file in codesandbox

const addBlock = (id, newBlock) => {
    const newBlockList = [...blocks];
    let index = newBlockList.findIndex((el) => el.id === id);
    if (index > -1) {
      newBlockList.splice(index, 0, newBlock);
      setBlocks(newBlockList);
    }
  };

Second Issue:

Since I am always adding the blocks above the droppable block. I am unable to figure out how to add the element to the last?

Please correct me what I am doing wrong? or any suggestions will be helpful.

about 4 years ago · Juan Pablo Isaza
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