NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
npm · #4697 most downloaded on npm
Drag and drop sans the GUI
Last release 4 years ago
no release in 18 months
Release timing varies
gaps range from 2 weeks to 9 months
Most releases are documented
notes for 50 of the last 60 stable releases
3 versions withdrawn
withdrawn after publishing
12 years old
93 releases · first in 2015
Nothing published for this version
## Major * Packages are now ESM-Only (https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c) * Node 18 Support
One column per quarter.
@react-dnd/asap has been simplified to remove the node variant, which relied on deprecated APIs
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
Nothing published for this version
All packages now have verified ESM support
pkg.exportsThis release uses output from swc using the 'es2017' target instead of using output from 'tsc' using the 'ESNext' target.
This release uses output from swc using the 'es2017' target instead of using output from 'tsc' using the 'ESNext' target.
This release fixes issues with the ESM-only structure of v15.0.0. All packages are now in their prior CommonJS/ESM format.
This release fixes issues with the ESM-only structure of v15.0.0. All packages are now in their prior CommonJS/ESM format.
~~The react-dnd packages are now published as ESM-only with type: module. See this FAQ by sindresorhus: https://gist.github.com/sindresorhus/a39789f98
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.
canDrag is true (#3187)Update internal hook useDragType() to align with updated typings. Check 14.0.0 release for API changes
Update internal hook useDragType() to align with updated typings. Check 14.0.0 release for API changes
This release addresses a handful of nagging liveness and ergonomic issues with the hooks API.
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 requiredspec.item can be a function or static object.spec.item replaces spec.beginSince 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},
})
Nothing published for this version
Nothing published for this version
Update .npmignore files so that tsbuildinfo files are not included in publication. This reduces package sizes.
Update .npmignore files so that tsbuildinfo files are not included in publication. This reduces package sizes.
Nothing published for this version
Add getDecoratedComponent() method to wrapInTestContext imperative API.
getDecoratedComponent() method to wrapInTestContext imperative API. (#2488)wrapInTestContext(#2486)react-dnd (#2491)Update Backends to use named exports for BackendFactory functions instead of default exports.
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).
useDragDropManager at top leveldnd-core: Use updated version @react-dnd/asap with browser variant support, this allows us to drop syntheticDefaultImports in dnd-core.
dnd-core: Use updated version @react-dnd/asap with browser variant support, this allows us to drop syntheticDefaultImports in dnd-core.
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 upda
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 )
The package.type=module setting has been removed. This proved to be a major pain point for users, and was technically problematic at this time. We wil
The package.type=module setting has been removed. This proved to be a major pain point for users, and was technically problematic at this time. We will eventually ship with package.type=module when NodeJS 12 drops out of maintenance and all of our dependencies ship ESM. (#1683)
The touch-backend has been updated to work-around iOS 13.x eventing issues (#1631) (thanks @zhusee2!)
Remove syntheticDefaultImport usage of react in react-dnd (#1629) thanks @sandersn . Fully removing syntheticDefaultImport from react-dnd is a WIP. We
syntheticDefaultImport from react-dnd is a WIP. We will need pure ESM versions of asap and hoist-non-react-statics. Ideally invariant and shallowequal would have ESM builds available as well, but there are forked ESM variants of these packages.Declare packages side-effect free for tree-shaking (#1577), thanks @maclockard
UMD builds are now shipped with the _react-dnd_, _react-dnd-html5-backend_, and _react-dnd-touch-backend_ packages in addition to _react-dnd-umd-build
(Typings) - Add getTargetIds to DragSourceMonitor interface declaration
Fixed some issues in react-dnd where named exports of interfaces were causing JS breakage
Add CJS builds to the core packages in order to facilitate better testing. (#1455, #1460)
All libraries
The react-dnd toolchain has been changed up from using TypeScript to using Babel. This allows us to use a ‘browserlist’ query instead of a coarse tsc
All Libraries Affected
The react-dnd toolchain has been changed up from using TypeScript to using Babel. This allows us to use a ‘browserlist’ query instead of a coarse tsc target when defining what JS features to ship with. The public API has not changed at all, but there could be underlying changes if your code is implementation dependent.
Remove DragDropContext decorator.
DragDropContext decorator. (#1439)dnd-core to accept a configuration object. (#1439)DragDropManagerImpl class (#1439)react-dnd-touch-backend libraryDndProvider to accept an 'options' prop with backend configurationThe DndProvider component had been throwing errors if it was rendered multiple times because of the implicit singleton invariant of the HTML5Backend.
<DndProvider backend={HTML5Backend}/>, it will only create a singleton instance of the DndContext per global context. This means that to create a second backend for an iframe, one needs to use:
<DndProvider backend={HTML5Backend} context={iframeWindow} />.The CommonJS libraries had runtime issues due to some @ts-ignore statements on non-typed module imports. Those have been removed from the core librari
The CommonJS libraries had runtime issues due to some @ts-ignore statements on non-typed module imports. Those have been removed from the core libraries.
__ES Modules__. The target output of TypeScript has been changed to esnext with esnext modules. This speeds up and simplifies our build process, and t
DragDragDropContextProvider~ => DndProviderDragDropContext, DragDropContextConsumer, and DragDropContextProvider~ => DndContext.The package.json files for the react-dnd libraries contained a "module" field which was used to identify where the ES Module roots began. These fields
The package.json files for the react-dnd libraries contained a "module" field which was used to identify where the ES Module roots began. These fields were added with the intent of supporting CommonJS module loading (the de-facto NodeJS module system) simultaneously with the ES Module loading system (the emerging standard for JavaScript modules).
Unfortunately this change resulted in a lot of build headaches for users then their module bundlers started defaulting to using the ES Module roots.
This release reverts that change and leaves the v7 branch of React-Dnd as primarily using CommonJS. ES Module builds are still available under the esm/ folders, but it is up to users to use them at their own discretion.
In v8, ES Modules are used as the default module system. CommonJS-based packages are still available however in react-dnd-cjs, and react-dnd-html5-backend-cjs
Release the Hooks API (#1381) (a5b0242), closes #1381
Allow __DragDropContextProvider__ to accept a manager prop
manager prop (#1362)Replace lodash with custom functions
getDecoratedComponentInstance() would throw invariant errors when used internallyString.endsWith polyfill for semver compatAdd a third argument to the collector functions in DragSource and DropTarget that includes the props of the current component. (e.g. collect(connect,
collector functions in DragSource and DropTarget that includes the props of the current component. (e.g. collect(connect, monitor, props)connectDragSource(ref))DragPreviewImage renderless component that wires up Drag Preview images.react-dnd-test-utils package, which exposes the wrapInTestContext utility functionThe hooks API will is currently __experimental__, and breaking changes of hooks may occur in non-major versions.
[patch] - #1249 - Check for uninitialized source/target identifiers
[patch] - #1250 - Use ES5 target for CommonJs builds.
[minor] - #1251, #1244, #1173 - Experimental Hooks API
This release includes an experimental hook-based React-Dnd API. Documentation for this feature still needs to be created, but the three public facing hooks are: useDragSource, useDropTarget, and useDragLayer.
The hooks API will is currently experimental, and breaking changes of hooks may occur in non-major versions.
const ref = useRef(); // pass in a ref instead of connectDragSource()
const { isDragging } = useDragSource(ref, ItemTypes.KNIGHT, {
beginDrag(monitor){ /* */ },
// collect function defined in specification
collect: monitor => ({
isDragging: monitor.isDragging(),
}),
})
return <div ref={ref}>...</div>
const ref = useRef(); // pass in a ref instead of connectDropTarget()
const { isOver, canDrop } = useDropTarget(ref, ItemTypes.KNIGHT, {
canDrop: () => canMoveKnight(props.x, props.y),
drop: () => moveKnight(props.x, props.y),
// collect function defined in specification
collect: monitor => ({
isOver: monitor.isOver(),
canDrop: monitor.canDrop(),
}),
})
return <div ref={ref}>...</div>
const props = useDragLayer(monitor => ({
item: monitor.getItem(),
itemType: monitor.getItemType(),
initialOffset: monitor.getInitialSourceClientOffset(),
currentOffset: monitor.getSourceClientOffset(),
isDragging: monitor.isDragging(),
}))
Add EsModule builds in addition to CommonJS builds
dropEffect=none setting on native DnD events (#1240)dataTransfer.items for files (#1241)dataTransfer.items for files (#1241) (96ff9ca), closes #1241 #712License Update The library was originally licensed as MIT, but during the transition to a Monorepo, the license was set to BSD 3-Clause. This release
License Update The library was originally licensed as MIT, but during the transition to a Monorepo, the license was set to BSD 3-Clause. This release corrects that error and restores the MIT license across all packages.
Nothing published for this version
Add 'debugMode' option to DndContext (#1190) (572955b), closes #1190
This required dropping support of TypeScript decorators in our examples, and may cause breaking changes for TypeScript users. The core issue is that T…
autobind-decorator library with class bind semantics, which eliminates that dependency.publishSource to true when options passed to beginDrag (#1161) (76cca25), closes #1161Remove the esModuleInterop setting from our tsconfig.json, this corrects typings for users who were not using esModuleInterop mode, and improves the b
Remove the esModuleInterop setting from our tsconfig.json, this corrects typings for users who were not using esModuleInterop mode, and improves the bundled library sizes.
UMD builds were missing from react-dnd and react-dnd-html5-backend in 4.0.2.
react-dnd and react-dnd-html5-backend in 4.0.2.Nothing published for this version
Nothing published for this version
React 17 prep - remove usage of lifecycle methods that are being deprecated
Breaking Changes:
Other Changes:
require()s with imports, which was causing grief for some users. This resulted in some culling of dependencies.decorateHandler. This check was not working correctly in certain situations, and resulted in silent failures. By just setting the ref directly, React will emit warnings about not being able to ref SFCs, which is more useful.This patch release changes the typescript transpilation from es2015 to es5. This should resolve some issues users had reported due to es2015 syntax.
This patch release changes the typescript transpilation from es2015 to es5. This should resolve some issues users had reported due to es2015 syntax.
3.0.0 was intended as a prerelease version (apologies for not including a -beta tag). This is the "final" 3.0 release.
3.0.0 was intended as a prerelease version (apologies for not including a -beta tag). This is the "final" 3.0 release.
The typings here have been updated to align more closely with the DefinitelyTyped react-dnd typings. They are much more accurate than in the prerelease.
Edit: please don't use this version, we discovered a critical issue with the documentation site.
In this release we've migrated the codebase to Typescript. The published libraries now have their own embedded typings definitions. It will remain an
In this release we've migrated the codebase to Typescript. The published libraries now have their own embedded typings definitions. It will remain an ongoing effort to improve the typings in our code.
Breaking Changes:
window from react-dnd. This should allow us to experiment with using react-dnd react-native. To support this, the DragDropContextProvider has been totally changed up. It now accepts a context object parameter that is backend-implementation dependent. Currently the HTML5Backend will need context to be { window }New Feature: Passing Derivative Props to DragLayer to minimize render cycles (#979).
Fixes an issue in the DragDropContextProvider where the backend was created on every render (#859) - thanks @WearyMonkey
refs with StatelessFunctionalComponents (#898) - thanks @knowbodyThis doesn't affect the packages, but the documentation was using some deprecated react/lib modules, and the react-hot-loader needed to be updated.
react/lib modules, and the react-hot-loader needed to be updated.Add React@16 to peer-dependencies to react-dnd
react-dnd peer-dependency from HTML5BackendCorrect SSR bug due to addEventListener and removeEventListener methods not being available in server-mode
addEventListener and removeEventListener methods not being available in server-mode (#813)babel-preset-env instead of babel-preset-latestMigrated deprecated React.PropTypes in example + same for React.createClass in docs (#729) (abbe4c7), closes #729
Nothing published for this version
Includes a fix for server-side rendering with the DragDropContextProvider #672, (thanks @liors)
Starting with this release, the packages will all be released simultaneously using the same version numbers.
Starting with this release, the packages will all be released simultaneously using the same version numbers.
Updates to Lodash 4 (#363, fecd21fcaab2f1482d4079aed335f4482cbf9d56)
latest branch. If you use Bower, point your config to npmcdn. For example: https://npmcdn.com/react-dnd@latest/dist/ReactDnD.min.jsFixes #261 hopefully for good—the change in 2.0.1 wasn't covering all cases
Your coding agent can read these notes before it upgrades. Set up the MCP server →