Drag source is not rendering at all
See original GitHub issueDescribe the bug
Component decorated with DragSource
is not rendered at all (render function is not called)
To Reproduce Write such component:
import * as React from "react";
import styled from "styled-components";
import {
DragSource,
DragSourceConnector,
DragSourceMonitor,
ConnectDragSource
} from "react-dnd";
const ImageHolder = styled.div`
margin: 10px;
max-width: 200px;
width: 200px;
min-height: 100px;
position: relative;
background-color: rgba(0, 0, 0, 0.5);
display: flex;
align-items: center;
`;
const ImageNameHolder = styled.div`
position: absolute;
bottom: 0;
left: 0;
right: 0;
padding: 10px;
background-color: rgba(0, 0, 0, 0.5);
font-size: 13px;
`;
interface Props {
imagePath: string;
connectDragSource?: ConnectDragSource;
isDragging?: boolean;
}
@DragSource<Props>(
"image",
{
beginDrag: (props: Props) => props.imagePath
},
(connect: DragSourceConnector, monitor: DragSourceMonitor) => ({
connectDragSource: connect.dragSource(),
isDragging: monitor.isDragging()
})
)
export class PhotosBrowserPhoto extends React.Component<Props> {
render() {
const { imagePath, connectDragSource } = this.props;
console.log({ connectDragSource });
return connectDragSource(
<div>drag me</div>
);
}
}
Expected behavior
Draggable component with drag me
text, connectDragSource
printed in the console
Actual behavior Nothing is rendered at all, console is empty
Issue Analytics
- State:
- Created 5 years ago
- Reactions:5
- Comments:15 (1 by maintainers)
Top Results From Across the Web
React Drag and Drop not working - Component rendering ...
Simple React DND form builder. The values when dropped, gets rendered twice. Any help is much appreciated. javascript · reactjs · react- ...
Read more >Mastering Drag & Drop with ReactJS | by Shay Keinan
I'm using styled-components for styling, we can pass props to the CSS and use them. Because we are going to render this component...
Read more >Rendering and previewing sequences - Adobe Support
In this Help article, learn how to render, preview, and playback sequences in Premiere Pro.
Read more >How To Fix Adobe Premiere Render and Export Errors (2022)
In this Adobe Premiere tutorial, I show you how to fix common render and export errors! Comment below with which fix worked for...
Read more >6 Proven Ways to Fix Sony Vegas Not Rendering Whole Video
Solution 1. Disable Render Loop Region Only. The Sony Vegas not rendering the whole video error can happen for several reasons, but in...
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 had to add the provider as shown below:
Adding provider component in root of my app solved the issue.
I think however - it should be clearly noted in example code that it’s needed - I thought seeing example is enough to understand how to start using library