Skip to content

What use is there to nesting DndContext if events don't go higher than the first parent? #766

Answered by clauderic
ABouchard55 asked this question in Q&A
Discussion options

You must be logged in to vote

Currently, the best way to do this is to have a single <DndContext> provider. You can dynamically change what modifiers are active or what the DragOverlay renders based on the type of active element.

You can also use useDndMonitor() to manage state locally rather than having to manage state at the top level of your application where <DndContext> is rendered.

You can leverage the data property of useDraggable and useSortable to store modifiers that should be applied when that type of draggable item is active, and also pass a component that should be rendered for the DragOverlay.

 function DraggableItem() {
  const {...} = useDraggable({
    id,
    data: {
      modifiers: [restrictToVerti…

Replies: 4 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@ABouchard55
Comment options

Answer selected by ABouchard55
Comment options

You must be logged in to vote
1 reply
@jamesgour
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
6 participants