useDrop DropTargetHookSpec accept type should include a function type
See original GitHub issueDescribe 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:
- Created 3 years ago
- Reactions:4
- Comments:6 (2 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.I noticed this too, but got around it by using
canDrop
.