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

Migrate from findDomNode to refs

Open senadir opened this issue 6 years ago • 5 comments
trafficstars

this is an initial PR to migrate from the now deprecated findDomNode to using ref

functionality wise this PR seems to work, there are however some problems that I could use some help in:

  • the flow types are not correct, I've never used flow before so I'm not sure how to fix and didn't have much time to research for it.
  • I couldn't run the tests from some reason (they run immediately but nothing happens).
  • I would rather refactor this to use forwardRef and use the same ref from Draggable into DraggableCore but it didn't work for some reason, but alas, the current approach still seems to work

senadir avatar Sep 15 '19 12:09 senadir

This is actually quite difficult to do well, because wrapped elements must properly forward refs down to the underlying DOM node, which is a very breaking change and will require significant modification on many apps that do something like:

<Draggable>
  <Panel>
    <Panel.Title>...</Panel.Title>
    <Panel.Body>...</Panel.Body>
  </Panel>
</Draggable>

I expect components to exert this kind of hygiene into React 17, but there will be some hard-to-solve edge cases.

STRML avatar Oct 29 '19 14:10 STRML

@STRML FYI https://github.com/reactjs/react-transition-group/blob/master/CHANGELOG.md#440-2020-05-05

vkrol avatar May 07 '20 14:05 vkrol

Interesting idea! I'd be happy to accept a PR with this.

On Thu, May 7, 2020, 10:37 AM Veniamin Krol [email protected] wrote:

@STRML https://github.com/STRML FYI https://github.com/reactjs/react-transition-group/blob/master/CHANGELOG.md#440-2020-05-05

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/STRML/react-draggable/pull/430#issuecomment-625294823, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAJEKP4NHQIMYS3MC4QC2NTRQLBTHANCNFSM4IW2PJQQ .

STRML avatar May 08 '20 03:05 STRML

@STRML If I understand correctly, this PR contains a similar solution.

vkrol avatar May 09 '20 19:05 vkrol

Unfortunately, it doesn't. The draggableRef and elementRef (why different names?) are ignored if passed in props.

STRML avatar May 11 '20 17:05 STRML