react-dnd Flashcards
what helps. react-dnd interact with dom
monitors: it is the way, react-dnd collects information what is happening
react-dnd creates state from events noted in monitor
how react-dnd give data to react components
collector function
react component gets props through collector function which convert Dnd state into props
what is a backend in react-dnd, types
backend is an abstraction over the dom, which outputs information about what drag and drop events are happening in the dom.
there are two types: 1. html-backend 2. touch-backend 3. Test: supports testing dnd interactions
drag sources
they are draggable component
carries information
drop targets
accept draggables
can execute functions based on events
how to convert a component into draggable
useDrag hook, it accepts, {item, collect} as props
it wires the component into a drag source
return value of useDrag hook
- ref to be attached to drag source
- collected props
- drag preview elements Ref: A connector function for the drag preview. This may be attached to the preview portion of the DOM