Skip to content

Commit b13450a

Browse files
committed
Update dnd documentation for composition
1 parent 2c0e2a7 commit b13450a

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

docs/api/querybuilder.mdx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -768,11 +768,22 @@ When the `independentCombinators` option is enabled, the `query` (or `defaultQue
768768

769769
Pass `true` to display a drag handle to the left of each group header and rule. Clicking and dragging the handle element allows visual reordering of rules and groups.
770770

771-
:::caution
771+
Drag-and-drop functionality is only enabled when `<QueryBuilder />` is wrapped in `QueryBuilderDnD` from the companion package [`@react-querybuilder/dnd`](https://www.npmjs.com/package/@react-querybuilder/dnd). [`react-dnd`](https://www.npmjs.com/package/react-dnd) and [`react-dnd-html5-backend`](https://www.npmjs.com/package/react-dnd-html5-backend) will also need to be installed.
772+
773+
```tsx
774+
import { QueryBuilderDnD } from '@react-querybuilder/dnd';
775+
import { QueryBuilder } from 'react-querybuilder';
772776

773-
Drag-and-drop features are only enabled when `<QueryBuilder />` is imported from the companion package [`@react-querybuilder/dnd`](https://www.npmjs.com/package/@react-querybuilder/dnd). [`react-dnd`](https://www.npmjs.com/package/react-dnd) and [`react-dnd-html5-backend`](https://www.npmjs.com/package/react-dnd-html5-backend) will also need to be installed.
777+
const App = () => (
778+
<QueryBuilderDnD>
779+
<QueryBuilder enableDragAndDrop />
780+
</QueryBuilderDnD>
781+
);
782+
```
783+
784+
:::tip
774785

775-
If your application already uses [`react-dnd`](https://react-dnd.github.io/react-dnd/), you should import and render `<QueryBuilderWithoutDndProvider />` instead of `<QueryBuilder />`. They are functionally the same, but the former will rely on your pre-existing `<DndProvider />` wrapper while the latter implements its own and will clash with a separate `<DndProvider />` higher up in the component tree (the error will typically look like this: "Cannot have two HTML5 backends at the same time.").
786+
If your application already uses [`react-dnd`](https://react-dnd.github.io/react-dnd/), wrap `<QueryBuilder />` in `QueryBuilderWithoutDndProvider` instead of `QueryBuilderDnD`. They add the same functionality, but the former will rely on your pre-existing `<DndProvider />`. The latter implements its own provider and will clash with a separate `<DndProvider />` higher up in the component tree. (If you use the wrong component, you will probably see the error message "Cannot have two HTML5 backends at the same time.")
776787

777788
:::
778789

0 commit comments

Comments
 (0)