react-dnd

Drag and Drop for React

MIT License

Downloads
36.2M
Stars
20.9K
Committers
208

Bot releases are hidden (Show)

react-dnd - v16.0.0 Latest Release

Published by darthtrevino over 2 years ago

Major

react-dnd - v15.1.2

Published by darthtrevino over 2 years ago

The utility packages @react-dnd/invariant, @react-dnd/shallowequal, and @react-dnd/asap (which are forks of popular libraries) have been included in the monorepo and built using the same output mechanisms as the react-dnd core packages (dual EJS/CSM).

@react-dnd/asap has been simplified to remove the node variant, which relied on deprecated APIs

react-dnd - v15.1.0

Published by darthtrevino over 2 years ago

  • All packages now have verified ESM support
  • Packages expose CJS/ESM surface are via pkg.exports
react-dnd - v15.0.2

Published by darthtrevino over 2 years ago

This release uses output from swc using the 'es2017' target instead of using output from 'tsc' using the 'ESNext' target.

react-dnd - v15.0.1

Published by darthtrevino over 2 years ago

This release fixes issues with the ESM-only structure of v15.0.0. All packages are now in their prior CommonJS/ESM format.

react-dnd - v15.0.0

Published by darthtrevino over 2 years ago

Major Changes

  • The react-dnd packages are now published as ESM-only with type: module. See this FAQ by sindresorhus: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c

  • The Decorators API has been removed and fully replaced by the Hooks API. The Decorators API was difficult to develop & type correctly, and this improves its maintainability.

  • The builds no longer use babel & preset-env. The library is transpiled using SWC into the "es2017" target, which assumes async/await is available. This should reduce bundle sizes by removing polyfills and support-code which may be unnecessary in your target.

Bugfixes

  • Improve data-transfer acquisition from File inputs (#3262)
  • Don't set the 'draggable' attribute unless canDrag is true (#3187)
  • Improve typings of DropTargetMonitor, DragLayerMonitor (#3300, #3341)
react-dnd - v14.0.3

Published by darthtrevino about 3 years ago

Updated

react-dnd: 14.0.3
react-dnd-html5-backend: 14.0.1
react-dnd-touch-backend: 14.1.0

Patch Updates

  • Fix drop operations in iframes & child windows (#3181) (thanks @eramdam!)
  • Refactor TouchBackend OptionsReader (#3291)
  • Cleanup connected DOM elements from react-dnd internals when hook-based components unmount (#3290)
  • Fix issue where custom drag-sources where triggering native drops in Firefox (#3272) (thanks @istateside)
react-dnd - v14.0.2

Published by darthtrevino over 3 years ago

Patch

This PR will throw a developer exception if a user specifies a useDrag::spec.begin method.

react-dnd - 14.0.1

Published by darthtrevino over 3 years ago

Patch

Update internal hook useDragType() to align with updated typings. Check 14.0.0 release for API changes

react-dnd - 14.0.0

Published by darthtrevino over 3 years ago

This release addresses a handful of nagging liveness and ergonomic issues with the hooks API.

The liveness issues affect all hooks, and were discovered on deeper inspection of certain stress tests in the documentation. The internal useCollector() hook is used to collect props from the DnD system when things change. Prior to this update, we subscribed to updates from the DnD monitor to trigger prop collection. However, state on the react side was only accounted for on the first render. This release improves that liveness by collecting props whenever react state changes.

The ergonomics of the useDrag have been refactored. In short:

  • spec.type is required
  • spec.item can be a function or static object.
  • The function version of spec.item replaces spec.begin

Since the release of the hooks API, we packed type under spec.item. However, this led to nonintuitive situations where an item field was required to be specified even though items are created in the begin method.

Additionally, in the original React-DnD design, beginDrag() was optional and the type of the draggables had to be defined. If no explicit DragObject was created, an implicit object was created by the system..

The change we've made here decouples type from item, and collapses begin into item.

// Pre-v14
useDrag({
   // item defined here to get a type
   item: { type: BOX } },
   // ...but the actual item is created here
   begin: () => ({ id })
})

// v14
useDrag({
   type: BOX,
   item: () => ({id})
})

e.g. useDrag({ item: { type: BOX }}) => useDrag({ type: 'BOX' })

We've also added the ability to cancel drag operations in the hooks API by returning null from begin.

// new API
useDrag({
  type: BOX,
  item: () => shouldNotDrag ? null : {id},
})
react-dnd - v13.1.1

Published by darthtrevino over 3 years ago

react-dnd

Patch

  • Re-register drag sources in hooks API when item.type changes
  • Export missing typings

react-dnd-html5-backend

Patch

  • Export HTML5Context, HTML5BackendOptions interfaces
react-dnd - v13.1.0

Published by darthtrevino over 3 years ago

react-dnd

TLDR: useDrag and useDrop support both a memo pattern and a spec object now.

useDrag(() => spec) // good
useDrag(spec) // also good

In v13, we've tried to address some errors that were pervading with the react-dnd hooks API. Generally, making sure DragSource/DropTargets were up-to-date and that the system wasn't leaking handles was a precarious balancing act. Moving to a memo API pattern (e.g. useDrag(() => spec)) fixed this problem in our tests.

However, as we dug further into handler leakage issues, it became clear that anything using the hooks would reattach and receive a new handler ID whenever the spec changed at all. This was in contrast to the Decorator API's behavior of keeping stable handler IDs as the incoming props changed.

To fix the Hooks API to stop leaking handlers, we found a pretty simple solution: a classical class with a public setter for the spec object that's updated via a useEffect hook. This neatly avoids the mutating DragSource/DropTargets on every spec change. This had two effects: identifiers have been stabilized, and spec objects were usable again because changing them didn't cause DragSource/DropTarget instances to be regenerated and reattached.

In retrospect, this undoes the necessity of the major cut that happened with v13, but the Hooks API is much sturdier now. We hope that you find the improved memory stability in the hooks API to be useful in your projects.

react-dnd - v13.0.1

Published by darthtrevino over 3 years ago

Patch Updates

  • Add invariant() invocations in useDrag, useDrop to verify that spec functions are used instead of objects
  • Fix handler registration memory leak issue with useDrag, useDrop
react-dnd - v13.0.0

Published by darthtrevino over 3 years ago

React-DnD v13, Others v12

v12 was largely structural and organizational, but some issues were discovered shortly after release that warranted changing the hooks API.

Breaking Changes

  • useDrag, useDrop hooks accept functions that create spec objects instead of spec objects directly. Clients can think about the API to useDrag() and useDrop() as being analogous to useMemo(). This allows clients to have direct control over when their DnD specifications are re-generated (which internally reattaches them to the DnD system).
  • Use jsx-factory throughout the library

Non-Breaking Changes

  • Add HTML native draggable type to HTML5Backend (see new example)
  • Clients can specify a rootElement component in the HTML5Backend options to localize where DnD will process events in the client app.
  • react-dnd-test-utils has improved support for testing with HTML5Backend and using @testing-library/react to simulate drag-and-drop sequences.
react-dnd - v11.1.3

Published by darthtrevino over 4 years ago

Patch

Update .npmignore files so that tsbuildinfo files are not included in publication. This reduces package sizes.

react-dnd - v11.1.2

Published by darthtrevino over 4 years ago

Patch

TouchBackend bug fix with _getDropTargetId (#2507)

react-dnd - v11.1.0

Published by darthtrevino over 4 years ago

Minor

  • Add getDecoratedComponent() method to wrapInTestContext imperative API. (#2488)

Patch

  • Improve typings of wrapInTestContext(#2486)
  • Eliminate module cycles in react-dnd (#2491)
react-dnd - v11.0.0

Published by darthtrevino over 4 years ago

Breaking Changes

Update Backends to use named exports for BackendFactory functions instead of default exports.

e.g.
import HTML5Backend from 'react-dnd-html5-backend
👇
import { HTML5Backend } from 'react-dnd-html5-backend

In general, throughout the app we've minimized the usage of default exports as well. They interfere with type correctness and screw with UMD builds (e.g. having to scrape a .default property off of a UMD global).

Minor Changes

  • Expose internal hook useDragDropManager at top level
  • Add profiling function to backend interface
  • Make handler functions public on backends

Patch Changes

  • Correct memory leak in drag previews (#2423)
  • Improve and correct typings
react-dnd - v10.0.2

Published by darthtrevino almost 5 years ago

Patch

dnd-core: Use updated version @react-dnd/asap with browser variant support, this allows us to drop syntheticDefaultImports in dnd-core.

react-dnd - v10.0.1

Published by darthtrevino almost 5 years ago

Patch

Fix UMD builds - our fork of ASAP was being brought in with node-specific code, breaking UMD builds. Using the canonical version of ASAP until we update our fork (#1684 )

Package Rankings
Top 0.34% on Npmjs.org
Top 12.29% on Repo1.maven.org
Top 6.68% on Proxy.golang.org
Top 22.4% on Clojars.org
Badges
Extracted from project README
npm version npm downloads Build Status codecov Dependabot Status