Skip to content
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

Hooks API Updates #1255

Merged
merged 12 commits into from Mar 8, 2019
Merged

Hooks API Updates #1255

merged 12 commits into from Mar 8, 2019

Conversation

darthtrevino
Copy link
Member

@darthtrevino darthtrevino commented Mar 8, 2019

Naming
useDragSource => useDrag
useDropTarget => useDrop

Specifications

  • Move ref object and type parameters into spec object on both
    useDrag({ref, type, ...})
    useDrop({ref, type, ...})

Moving some examples over to hooks as a test-bed. Currently the simple-sortable example can get out of sync with the dragdrop state

Reverting the documentation to using the class-based API so that newcomers do not think the hooks API is idiomatic at this point.

NOTE:
The hooks API will be placed inside of a super annoying namespace in react-dnd until it's ready for production:

import {__EXPERIMENTAL_DND_HOOKS_} from 'react-dnd'
const { useDrag, useDrop} = __EXPERIMENTAL_DND_HOOKS_

@darthtrevino darthtrevino changed the title Improvements on Hooks API Improvements on Hooks API (WIP) Mar 8, 2019
@darthtrevino darthtrevino changed the title Improvements on Hooks API (WIP) Hooks API Updates Mar 8, 2019
@darthtrevino darthtrevino merged commit d047a1a into master Mar 8, 2019
@darthtrevino darthtrevino deleted the feature/hooks_refinement branch March 8, 2019 03:10
@brason
Copy link

brason commented Mar 9, 2019

Great to see support for hooks! Do you have an idea of how long till it's production ready?

@darthtrevino
Copy link
Member Author

Thanks! I don't have a fixed time-range for when the hooks-based API will be ready, but the main things I'd like to see are:

  • Some more feedback on the hook-based API (it's still very fluid at this point)
  • The hook-versions of the examples all have parity to the decorator-based versions. Right now the sortable-list example acts a little wonky and the "stress test" sortable list is noticeably slower than the decorator based version.

darthtrevino added a commit that referenced this pull request Feb 3, 2022
* docs: move the simple sortable example to hooks

* refactor: rename useDragSource to useDrag, useDropTarget to useDrop

* refactor: update dragSource/dropTarget specs to include ref and type

* refactor: cleanup in useDrag, useDrop

* docs: spelling correction

* refactor: move internal hooks to an internal folder

* refactor: break up the interfaces a bit

* refactor: rename beginDrag => begin, endDrag => end

* refactor: put the hooks feature behind an annoying name

* refactor: revert the canonical examples to using the class-based api

The hook-based examples will be in another package for now

* fix: ts issues
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants