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
[IFRAME] Uncaught TypeError: Cannot read property 'unshift' of undefined when dragging #435
Comments
Sorry you're having trouble :/. What browser are you using? Can you show how you're creating the |
Thanks for the quick reply. I'm using Chrome latest. App.cjsx HTML5Backend = require('react-dnd-html5-backend')
{ DragDropContext } = require('react-dnd')
class App extends React.Component
#internal logic
module.exports = DragDropContext(HTML5Backend)(App) AFAIK I follow exactly what the doc explains, I'm following the tutorial right now to see if I haven't missed a step. |
Okay, I think I found out why. It's because my components are within an Iframe using When I setup my components exactly the same way outside of the iframe, it seems to work fine. |
Ah that explains it! The code that's not running is in handleTopDragStartCapture() {
this.clearCurrentDragSourceNode();
this.dragStartSourceIds = [];
} and this is bound like Are you using an iframe per component? Or just one that your drag&drop components live within? |
I'm using only one iframe which contains my Pattern elements, those Pattern can be drag & dropped. |
I think I just understood that I actually just needed to execute the In the meantime, I've changed the code of the HTML5Backend to apply/remove listener on an array of targets, which are my iframe.contentDocument and window so I can have DnD everywhere. :) |
Hmm, I am getting this issue without using iframes. Perhaps related to some other, unrelated component doing it's on drag and drop thing. I noticed that this.dragOverTargetIds is not initialized in the constructor, and the error occurs because handleDragOver fires before that property is ever initialized. Would it not be best to either initialize taht property, or gate the handler correctly that it only fires when required? I feel this is a bug. |
Might fix the problem, not sure it's the best way though
|
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. |
I get the following message when I'm dragging my item:
Uncaught TypeError: Cannot read property 'unshift' of undefined
.I looked at the error and found out that the following code was throwing the exception.
So, I took a look at
this
:The field
dragStartSourceIds
simply doesn't exist.Here is my code (CJSX)
The component itself is wrapped into another component (many levels higher), my App component, basically, as explained in the doc.
The drag action itself works, but I'm trying to implement the drop now and was trying to simply display a class when the component is being dragged and it fails because of the exception.
What did I do wrong? I'm just getting started with it.
The text was updated successfully, but these errors were encountered: