drop Specification of useDrop hooks api is always taking initial state instead of updated state

Solution 1:

Hi I've been throught the same issue for the past two days. Try this to solve your issue.

const [{ canDrop, isOver }, drop] = useDrop(() => ({
accept: ItemTypes.BOX,
hover: () => {
  setTest(true);
},
drop: () => {
  console.log(test, "drop");
  return { name: "Dustbin" };
},
collect: (monitor) => ({
  isOver: monitor.isOver(),
  canDrop: monitor.canDrop()
})}),[test]);

Without [test] drop won't "see" the update state, but i don't really know why for now.