-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* docs: clean up native file example * test: add an example case to demonstrate flaw with current hook api * fix: replace refs in useDrag,useDrop with connector functions * feat: work on hooks, perf improvements * refactor: clean up usedrag/usedrop hooks * refactor: clean up the number of hook files * feat: use callback refs in hooks api * feat: memoize drag/drop specs * fix: class api typings * feat: remove the 'preview' option of the drag spec * feat: update previews, documentation * refactor: move isRef * refactor: create SourceConnector, TargetConneector classes * fix: hooks isuses * refactor: make the hooks field constant in the connector classes * fix: reconnect connectors on target change * docs: clean up knight component * fix: add typings to useCollector arguments * fix: tighten typings on dragdrop monitors * fix: some liveness issues, hooks are still wonky atm * refactor: decouple useCollector/useMonitor output from connector types * docs: update usedetachedcomponent docs * fix: correct issues with detached previews, rename the hook to useDetachedPreview * docs: remove previewproperty from dragspec in useDetachedPreview * revert: eliminate implicit memoization. BYOM(emoization of specs) * refactor: clarify the ref mechanism is decorateHandler. Remove recompose since the ref objects will be harmless on FCs * fix: scope down the drag preview wrapper Because of the limitations with drag previews, we can't use arbitrary components, only Image elements. Because of this, we've retooled the DisconnectedDragPreview HOC to be just a DragPreviewImage component which can render disconnected images. * docs: add drag-preview-image docs to sidebar * refactor: replace the portaling mechanism with a renderless component This mechanism for showing drag previews is much, much simpler, but still allows clients to use image previews as components. * docs: add some notes to the new examples
- Loading branch information
1 parent
aa584be
commit 7779463
Showing
80 changed files
with
1,042 additions
and
817 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
packages/documentation/markdown/docs/01 Top Level API/DragPreviewImage.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
--- | ||
path: '/docs/api/drag-preview-image' | ||
title: 'DragPreviewImage' | ||
--- | ||
|
||
_New to React DnD? [Read the overview](/docs/overview) before jumping into the docs._ | ||
|
||
# DragPreviewImage | ||
|
||
A Component to render an HTML Image element as a disconnected drag preview. | ||
|
||
### Usage | ||
|
||
```js | ||
import HTML5Backend from 'react-dnd-html5-backend' | ||
import { DragSource, DragPreviewImage } from 'react-dnd' | ||
|
||
function DraggableHouse({ connectDragSource, connectDragPreview }) { | ||
return ( | ||
<> | ||
<DragPreviewImage src="house_dragged.png" connect={connectDragPreview} /> | ||
<div ref={connectDragSource}>🏠</div> | ||
</> | ||
) | ||
} | ||
export default DragSource( | ||
/* ... */ | ||
(connect, monitor) => ({ | ||
connectDragSource: connect.dragSource(), | ||
connectDragPreview: connect.dragPreview(), | ||
}), | ||
) | ||
``` | ||
|
||
### Props | ||
|
||
- **`connect`**: Required. The drag preview connector function |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 0 additions & 41 deletions
41
packages/documentation/markdown/docs/05 Hooks-Based API/useDragPreview.md
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
packages/documentation/markdown/examples/other/drag-source-rerender.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
path: '/examples/other/drag-source-rerender' | ||
title: 'Drag Source Rerender' | ||
--- | ||
|
||
[JavaScript](https://github.com/react-dnd/react-dnd/tree/gh-pages/examples_js/06%20Other/Drag%20Source%20Rerender) | ||
[TypeScript](https://github.com/react-dnd/react-dnd/tree/master/packages/examples/src/06%20Other/Drag%20Source%20Rerender) | ||
|
||
Regression example using a drop target that's connected as a child | ||
|
||
<other-drag-source-rerender></other-drag-source-rerender> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.