Skip to content

Programatically moving items giving wrong transforms #980

Answered by mattrunyon
mattrunyon asked this question in Q&A
Discussion options

You must be logged in to vote

I figured something out. I needed to manually schedule a remeasure whenever the items changed. I'm controlling the items externally, so the items prop changes whenever the buttons are clicked.

const context = useDndContext();
const contextRef = useRef(context);

useEffect(() => {
  contextRef.current = context;
}, [context]);

useEffect(() => {
  contextRef.current?.measureDroppableContainers([
    ...contextRef.current.droppableContainers.keys(),
  ]);
}, [items]);

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@phunanon
Comment options

@phunanon
Comment options

Answer selected by mattrunyon
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants