react-draggable
react-draggable copied to clipboard
Migrate from findDomNode to refs
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
forwardRefand use the same ref fromDraggableintoDraggableCorebut it didn't work for some reason, but alas, the current approach still seems to work
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 FYI https://github.com/reactjs/react-transition-group/blob/master/CHANGELOG.md#440-2020-05-05
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 If I understand correctly, this PR contains a similar solution.
Unfortunately, it doesn't. The draggableRef and elementRef (why different names?) are ignored if passed in props.