본문 바로가기
부트캠프교육중/react

[React] 다른 board끼리의 움직임

by 뭉지야 2023. 9. 8.
728x90

1. 먼저 sourceboard의 복사본을 만들어줘야한다.

const sourceBoard = [...allBoards[source.droppableId]]



2. target도 만들자

const destinationBoard = [...allBoards[destination.droppableId]]



3. 지우고 추가하고 하자

sourceBoard.splice(source.index, 1);
destinationBoard.splice(destination?.index, 0, draggableId)



4. 모두 출력하자

return {
  ...allBoards,
  [source.droppableId]: sourceBoard,
  [destination.droppableId]: destinationBoard,
}
728x90

'부트캠프교육중 > react' 카테고리의 다른 글

[React] 진짜 미친 Framer motion이다  (0) 2023.09.11
[React] MotionValue에서 console.log  (0) 2023.09.11
[React] 같은 board안에서의 움직임  (0) 2023.09.08
[React] React.memo  (0) 2023.09.08
[React] Recoil 정리  (0) 2023.09.05