question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cant use ref over nested components

See original GitHub issue

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>

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:4
  • Comments:5

github_iconTop GitHub Comments

1reaction
bo-careycommented, Dec 2, 2020

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

0reactions
wuarmincommented, Aug 24, 2022

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?

Read more comments on GitHub >

github_iconTop Results From Across the Web

React ref a nested component - Stack Overflow
Yes, child ref is accessible since it is part of real DOM. I made a simple example with two nested components, check it...
Read more >
v7 register forward refs failed with nested components #4913
Describe the bug register forward refs failed while nesting components. Expected behavior ref to be created properly with the spread ...
Read more >
Forwarding Refs - React
Ref forwarding is a technique for automatically passing a ref through a component to one of its children. This is typically not necessary...
Read more >
Using Template Reference Variables to Interact with Nested ...
We can't access the @ViewChild variable in ngOnInit , ngOnChanges , or ngDoCheck because it can be accessed only after our view is...
Read more >
React Stripe.js reference | Stripe Documentation
The Elements provider allows you to use Element components and access the Stripe object in any nested component. Render an Elements provider at...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found