New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Warning With Nested DragSource #431
Comments
👍 |
Can you please provide a project reproducing the problem? |
I'm trying to produce an simple example and am having problems reproducing outside of my private project that I'm working on. @nihtalak , do you have a repo on Github that produces the issue? |
Here's a tiny repo exhibiting the described behavior: https://github.com/ebakan/react-dnd-nested-bug |
Curiously, the |
It will also throw the error when listening to |
@ebakan - interesting. I'm wondering what's causing this bug to appear in my code, which does use isDragging. I am doing some wonky things with the nested draggable, so it could be a manifestation of the same bug you are seeing. Thanks for the help reproducing! |
I have nested draggables too, but not sure if thats the issue. Update: found the issue, I had a leftover listener so in my case it wasn't due to react-dnd. |
I just added Dnd to another component and noticed this issue even without nested or multiple dragging components. After a bit of digging I found that the issue is connected to custom drag layer rendering the component while being dragged. If I put text instead the component being dragged it works fine. The component itself is the drag source. |
@jchristman @hakunin I don't have nested draggables, but encountered render() {
var dropZone;
if (this.props.isDragging) dropZone = <MyDropTarget />;
return <div>
<MyDragSource />
{dropZone}
</div>
} Ended up working around it by using |
I think that could be the issue. I will check and let you know. That's is definitely the construct I'm using right now. |
Naw - I'm getting the issue when the "drop" happens. Then it tries to rerender the component and throws this warning. |
Got same warning when my drag preview was a component which was a DragSource (which I'm not supposed to do). |
@jchristman did you ever come up with a solution for this? Im working with nested dragSources and suddenly started seeing this error when dropping the nested resource. I can provide an example but wanted to see if anyone had solved the issue, or had a suitable workaround. |
Thanks @arjunu my warning was caused by this! |
@gharwood1, I'm just livin with the issue until it can be fixed. I spent a few hours once trying to really understand this library so I could pull request a fix but it's pretty complex, so I moved on. I just don't have the time... :-( |
@gaearon I don't quite have a project made that's capable of someone pulling down, but I think I can get one made if needed. Basically, is what I'm trying to do here valid: If I disable the conditional in line 64 everything's fine if (this.props.draggingSubject){
effectiveChildren.push(this.props.draggingSubject);
} but the minute the results of the drag event starts modifying props and rendering of components, the warning above starts getting spit out frequently. Should I not be doing this? The use case is basically to "preview" the currently dragged item in the drop target. The above is a proof of concept - not wired into the Redux store yet, since I'm not sure if this is even valid. Hm, looks like it's fine if I keep my changes local to |
I'm experiencing exactly the same problem. What you can do in some situations is create a |
I got the same error, except I am doing a nested dropTargets.
(with the shallow is true option) in the canDrop function of the parent dropTarget, and the issue went away. I would think the same could be applied to some other scenarios. |
@jchenjc I tried this but it didn't work for me. To be honest my situation is extremely complicated with nested drag preview + drag source + drop target that needs to work across lists. |
FWIW: I have both nested drag sources and a custom drag layer. When I remove the custom drag layer, the message goes away. From inspecting the stack trace, it looks like the problem is here:
Relevant code is here. I'm going to look into why the state might be different in my case to trigger a re-render... |
With a dragsource+droptarget nested inside a droptarget, I get this issue. |
Part of the reason this happened is because gaearon envisoned doing list drag and drop by making every list item a drop target, rather than making the list component a single drop target that determines what to do based upon the drag hover position. The latter way is how most other DnD systems I've seen do things. |
Just in case it helps someone: I encountered this when I was rendering a component that was a drag source in my custom drag layer because it was convenient. I used the drag source component because it was the same entity that I was trying to drag, so it just made sense to me to keep the code "DRY" by reusing it. I didn't think about the fact that it had all the dragSource code in it - looking back, of course I wouldn't want a drag source AS the thing to render in the custom drag layer. I ultimately split up my component into a "Draggable" version that wrapped the base component, and then used the base component in my custom drag layer. No more warning, better code! 👍 |
@davidjoy woah, thanks for sharing! I am doing the same thing, need to try it as well! |
@davidjoy Just fixed mine as well. Your suggestion points to not using DragSource and such for the custom layer. What I did was simply to use the naked component without DragSource in my custom drag layer and that did the trick. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
If you have a DragSource inside of a component that is also a DragSource (i.e. drag something within a draggable), whenever the parent component is dragged, the following warning appears.
An example of this would be:
I believe the issue stems from the fact that rerendering the parent component causes the child DragSource call to make a call to setState during receiveProps function call?
The text was updated successfully, but these errors were encountered: