-
Notifications
You must be signed in to change notification settings - Fork 715
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
typescript(vx-drag): re-write package in TypeScript #499
Conversation
packages/vx-drag/src/Drag.tsx
Outdated
y: resetOnStart ? point.y : -dy + point.y, | ||
}; | ||
if (onDragStart) onDragStart({ ...nextState, event }); | ||
this.setState(() => nextState); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be this.setState(nextState);
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah good question, I'm not sure there's a compelling reason to use the functional variant here since we are not referencing any existing values.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I refactored this to use functional setState
with a callback for onDrag*
. This should use freshest state
and throttle onDrag*
calls in sync with setState
updates. Have to invoke event.persist()
cda111e
to
5cac2c4
Compare
0f2697b
to
d7cb3ba
Compare
d7cb3ba
to
40f8643
Compare
ebffcf3
to
115df87
Compare
omg finally lol |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! one minor type issue about MouseEvent & TouchEvent. Should be good to go after that.
packages/vx-drag/src/Drag.tsx
Outdated
isDragging: false, | ||
}; | ||
|
||
handleDragStart = (event: React.MouseEvent) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these could also be TouchEvent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch, did a sweep 🧹
Oi, type errors for vx-responsive + vx-text 🤔 |
I added types to the |
RE: lodash dep #66 |
9e15a1e
to
afe9aff
Compare
ahhh, ic. reverted and just added I think this is also failing the build in #512 . |
🚀 Enhancements
This PR builds off of #488 which added TypeScript build support, and converts the
@vx/drag
package toTypeScript
.Depends on #493 (for
@vx/event
types), and closes #498.💥 Breaking Changes
React.Fragment
s, which requires bumping thepeerDep
forreact
to^16.3.0-0
<g>
wrapper aroundDrag
children
was replaced with aReact.Fragment
which removes a DOM element.Testing
/drag-i
and/drag-ii
@hshoff @schillerk @milesj @techniq @kristw