question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

onDrop, receiving console error node.contains is not a function

See original GitHub issue

Do you want to request a feature or report a bug?

  • I found a bug
  • I want to propose a feature

What is the current behavior? All functionality works as expected, however, when dragging and dropping files there is always this console error: Uncaught TypeError: r.node.contains is not a function at HTMLDocument.r.onDocumentDrop

If the current behavior is a bug, please provide the steps to reproduce.

With the following code:

<Dropzone
      className={classes.dropzone}
      accept="image/jpeg, image/png"
      onDrop={onDrop}
      id="poster-dropzone"
    >
      {({ getRootProps, getInputProps, isDragActive }) => (
        <Paper
          {...getRootProps()}
          className={classNames({
            [classes.posterArt]: true,
            [classes.hoverPoster]: isDragActive,
          })}
          elevation={8}
        >
          <input {...getInputProps()} />
          <Masonry>
            {posterFiles.map(poster => (
              <PosterThumbnail
                key={poster._id}
                data={data}
                onChange={onChange}
                poster={poster}
                posterTitle={getPosterTitle(posterTypes, posterMetadata, poster._id)}
              />
            ))}
          </Masonry>

          <div className={classes.addIcon}>
            <Add />
          </div>
        </Paper>
      )}
    </Dropzone>

Clicking the input to upload works with no problems. But when dragging and dropping, the upload works, but I get this error: Uncaught TypeError: r.node.contains is not a function at HTMLDocument.r.onDocumentDrop Upon inspecting this error, I see it takes me to the minified react-dropzone dist/index.js

What is the expected behavior?

For the functionality to work with no console errors.

Please mention other relevant information such as the browser version, Operating System and react-dropzone version.

Testing in Chrome on macOs Mojave. Using react-dropzone 8.1.0

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:8

github_iconTop GitHub Comments

2reactions
pauldiloretocommented, Feb 21, 2019

@rolandjitsu Thanks for your response! Unfortunately, adding the refKey: 'innerRef' gave me some console error about refs not working on function components.

However, simply wrapping my <Paper> component with <div {...getRootProps()}> fixed the issue. Thanks!

1reaction
rolandjitsucommented, Mar 28, 2019

@vanyakosmos we already have this sort of issue example in our docs, but for styled components. Since they moved away from innerRef, I think it’s a good idea to use mui instead as example for setting references using custom refKey.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why is this returning the error .contains() is not a function
Am getting the error .contains() is not a function. Full code is here, probably too much to paste here so here's the relevant...
Read more >
How to solve contains is not a function in JavaScript - Reactgo
The “contains is not a function” error occurs when we call a contains() method on a value other than the dom nodes. To...
Read more >
Process | Node.js v19.3.0 Documentation
The 'beforeExit' event is emitted when Node.js empties its event loop and has no additional work to schedule. Normally, the Node.js process will...
Read more >
Event loops - HTML Spec
JSON module scripts represent a parsed JSON document. As CSS stylesheets and JSON documents do not import dependent modules, and do not throw...
Read more >
Drag'n'Drop Event Handling Gotchas I Wish I Knew Earlier
files as empty but it's not! When you process dropped files in the onDrop handler and want to console.log event and check if...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found