Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

219
Views
Cambiar la lista de elementos no vuelve a representar el componente cuando se usa react-beautiful-dnd

Estoy usando react-beautiful-dnd para permitir que el usuario elija las opciones usando arrastrar y soltar.

Sin embargo, el componente no parece volver a renderizarse cuando se cambia el orden de las opciones. (He intentado iniciar sesión en la consola y parece haber cambiado).

Este es el método onDragEnd :

 const onDragEnd = (result) => { if (!result.destination) return; const { source, destination } = result; if (!destination) { return; } if (source.index === destination.index) { return; } let items = [...list]; const [removed] = items.splice(source.index, 1); items.splice(destination.index, 0, removed); setList([...items]); };

Todo el código se puede encontrar en este codesandbox .

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Está representando cursos optionalCourses en el DND pero está actualizando el estado de la lista. Debería representar la list en su lugar.

 return ( <div className={componentClassName}> <span className={`${componentClassName}__title`}>{groupTitle}</span> <DragDropContext onDragEnd={onDragEnd}> <Droppable droppableId={groupId}> {(provided, snapshot) => ( <div {...provided.droppableProps} ref={provided.innerRef} className={`${componentClassName}__list`} > > {list.map((optionalCourse, index) => { > return <OptionalCourseCard key={index} {...optionalCourse} />; })} {provided.placeholder} </div> )} </Droppable> </DragDropContext> </div> );
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!