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.

useDrop DropTargetHookSpec accept type should include a function type

See original GitHub issue

Describe the bug Your documentation of useDrop says that the specification object member accept is “A string, an ES6 symbol, an array of either, or a function that returns either of those, given component’s props.”. But in the code, accept is defined as TargetType, which is string | symbol or an array of those.

Expected behavior accept should be a type where a function which returns TargetType is possible.

Additional context I want to update accept dynamically. I thought this would be possible by changing the accept value of useDrop but this doesn’t work. I currently don’t see how to do this otherwise and I can’t find the behavior the documentation describes.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:4
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
johanneslumpecommented, Aug 20, 2020

I know this isn’t an ideal solution, but until this is solved and we can have target type-production functions, a workaround would be to use a key property equal to your accepted types on the component which contains your drop target. This would ensure that it re-mounts once you change the acceptable type(s). I just ran into this exact issue myself today.

1reaction
dhulmecommented, Oct 6, 2020

I noticed this too, but got around it by using canDrop.

Read more comments on GitHub >

github_iconTop Results From Across the Web

useDrop - React DnD
This function returns an array containing a ref to attach to the Drop Target ... to the items produced by the drag sources...
Read more >
react-dnd@16.0.1 - jsDocs.io
The memoization deps array to use when evaluating spec changes ... Returns a string or a symbol identifying the type of the current...
Read more >
How to use the react-dnd.useDrop function in react-dnd | Snyk
To help you get started, we've selected a few react-dnd.useDrop ... isDragging(), }) }); const [{ isHovered }, drop] = useDrop({ accept: type,...
Read more >
react-dnd useDrop TypeScript Examples - ProgramCreek.com
The following examples show how to use react-dnd.useDrop. ... dropClassName }, drop] = useDrop({ accept: type, collect: (monitor) => { const { index: ......
Read more >
Spec.Type Must Be Defined In Reactdnd - ADocLib
useDrop DropTargetHookSpec accept type should include a function type #2732 But in the code accept is defined as TargetType which is.
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