After 7.4.5 this.props.connectDragPreview(getEmptyImage() fails intermittently
See original GitHub issueDescribe the bug
After 7.4.5 this.props.connectDragPreview(getEmptyImage())
fails intermittently
To Reproduce Steps to reproduce the behavior:
- Implement a draggable item
this.props.connectDragPreview(getEmptyImage())
- Use 7.4.5, see it works
- Use any 7.X later than that and see a drag preview that shouldn’t be there
Expected behavior If I don’t want to see the default “transparent drag image” I shouldn’t
Screenshots
The “token” is being dragged down and to the left. Large card is my <CustomDragLayer />
as expected and the transparent “token” is the default react-dnd drag preview I have explicitly turned off
Desktop (please complete the following information):
- OS: Linux, Windows, macOS
- Browser electron
- Version 4.X
Additional context Love the library, looking at upgraded to 8.x so I can’t say for sure if it happens in the 8 branch but 7 is DEFINITELY having a regression!
Issue Analytics
- State:
- Created 4 years ago
- Reactions:4
- Comments:19 (6 by maintainers)
Top Results From Across the Web
How does react-dnd's connectDragPreview() work?
The standard preview appears with this code. I then tried to wrap my connectDragSource in my component's render() method with connectDragPreview ...
Read more >Top 5 react-dnd-html5-backend Code Examples - Snyk
componentDidMount() { // Replace the native drag preview with an empty image. this.props.connectDragPreview(getEmptyImage(), { captureDraggingState: true, }); ...
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
No no, sorry, I’m not a contributor to react-dnd. What I meant is that I was suffering the same issue, but rewrote my component to use the hooks API instead of the ‘Legacy Decorator API’. It seems like the bug is specifically contained to the Legacy Decorator API. I had a look in the code changes for 7.0.0 but couldn’t see anything that should cause this. See the docs (http://react-dnd.github.io/react-dnd/about) You will need v7.6.0 or above, but it will possibly resolve your issue.
An example of the difference would be:
Before:
After:
I’ve just tried this myself, and can confirm this fixes the issue for me. @darthtrevino