react-draggable icon indicating copy to clipboard operation
react-draggable copied to clipboard

Cant use ref over nested components

Open JoaquinDelPrado opened this issue 4 years ago • 5 comments

im trying to use nodeRef to handle my draggable component but i get a bad manner on it. Here is a basic example of my code:

<Draggable axis="y" nodeRef={draggableRef}>
   <div>
     <div ref={draggableRef}>
        Click here to drag the component!! 
     </div>
  <div>
</Draggable>

JoaquinDelPrado avatar Jul 30 '20 01:07 JoaquinDelPrado

Having the same issue. Using ref on nested elements makes dragging very choppy.

<Draggable nodeRef={handler}>
    <div id="window">
        <div id="header" ref={handler}></div>
        <div id="body"></div>
    </div>
</Draggable>

*note that I am using a class component so I use const handler = createRef(null); instead of useRef

bo-carey avatar Dec 02 '20 17:12 bo-carey

thanks for your approach @jellyfith!! i'll try your way

JoaquinDelPrado avatar Dec 02 '20 18:12 JoaquinDelPrado

@JoaquinDelPrado what was your solution to this problem. I'm experiencing the choppy drag behavior when using nodeRef on any child div of the Draggable component.

sseagull avatar Feb 04 '22 20:02 sseagull

@JoaquinDelPrado I'm facing the same issue, how did you resolve it on your end?

kroussea avatar Aug 19 '22 13:08 kroussea

I have the same issue. I want to use nodeRef on nested handler, but then the dragging is very choppy. @STRML Do you know the reason. How can we fix this?

wuarmin avatar Aug 24 '22 09:08 wuarmin