Among the options
passed to the onDrop
callback, dragSourceId
and dragSource
are now optional.
If the drag source is an element external to DndProvider
or a file or selected text, these will be undefined
.
Therefore, if you are using options.dragSource
or options.dragSourceId
in your onDrop
callback, you may need to check whether these values are undefined
or not.
<Tree
{...someProps}
onDrop={(tree, options) => {
console.log(options.dragSource.id);
}}
/>
<Tree
{...someProps}
onDrop={(tree, options) => {
if (options.dragSource) {
console.log(options.dragSource.id);
}
// or
console.log(options.dragSource?.id);
}}
/>
react-dnd
is no longer included in this package, so users of this package must separately install the latest version of react-dnd
and import DndProvider
.
import { Tree } from "@minoru/react-dnd-treeview";
function App() {
return <Tree {...props} />;
}
import { DndProvider } from "react-dnd";
import {
Tree,
MultiBackend,
getBackendOptions,
} from "@minoru/react-dnd-treeview";
function App() {
return (
<DndProvider backend={MultiBackend} options={getBackendOptions()}>
<Tree {...props} />
</DndProvider>
);
}