question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

I need to know when I drag over and when I drag out from a drop target.

I can use hover for the first use case.

I’d need something like a leave callback.

Do I miss how this is done or is this a strange use case?

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:4
  • Comments:5

github_iconTop GitHub Comments

4reactions
aiven715commented, Aug 30, 2020

why they don’t have it here.

@Kivylius Most likely it’s not there since the library is declarative by it’s nature. Using onEnter and onLeave is the imperative way of doing things where in most cases you change the state to understand whether the item is dragged over or not, which you can achieve with monitor.isOver() function.

But there are the exclusive cases where you need to produce a side-effect once the item leaves or enter drop area.

I’ve came up with a following solution(however not tested it thoroughly so it might fail in some cases):

// "isOver" and "didDrop" variables are coming from "collect" function in "useDrop"
const useLeave = (callback, isOver, didDrop) => {
  const ref = useRef(isOver)

  useEffect(() => {
    if (ref.current && !isOver && !didDrop) {
      callback()
    }

    ref.current = isOver
  }, [isOver, didDrop])
}
2reactions
kserjeycommented, Dec 22, 2020

Don’t know if it will work properly, but as a temporary solution I just used onDragLeave property:

<Component onDragLeave={() => resetHoverState()}/>
Read more comments on GitHub >

github_iconTop Results From Across the Web

Leave callback function - javascript - Stack Overflow
1 Answer 1 ... You're looking for the return statement. app.get("/", function(req, res) { if( some_func() == 0 ) { res.send("some_func() returned ...
Read more >
Approved Leave Callback Sample Clauses - Law Insider
An approved leave callback is a recall to duty of an employee for any reason once leave has been approved and the affected...
Read more >
Exit Callback Functions (The GNU Awk User's Guide)
An exit callback function is a function that gawk calls before it exits. Such functions are useful if you have general “cleanup” tasks...
Read more >
How can i use leave meeting callBack use for Component ...
I have implemented web sdk 4.0.0 Component View into react. React version is "react": "^17.0.1", When i click on the Leave meeting button...
Read more >
How to leave callback Output unchanged - Dash Python
Hi. I want to not change the Output of a callback when certain conditions are met. If I just do return, the output...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found