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.

React-Dropzone throws errors since 8.0.0 (after the breaking changes)

See original GitHub issue
  • I found a bug
  • I want to propose a feature

What is the current behavior? React-Dropzone throws errors since 8.0.0, after the breaking changes

<Dropzone>
  {({getRootProps}) => <div {...getRootProps()} />}
</Dropzone>

If the current behavior is a bug, please provide the steps to reproduce. Tried adding the props to my code, tried the examples, none of them work.
I’m using Windows 10 pro 64bit, node v8.12.0. Tested both react-dropzone 8.0.0 and 8.0.1.

TypeError: children is not a function  
render  
.../node_modules/react-dropzone/dist/es/index.js:474  

  471 | var isMultipleAllowed = multiple || filesCount <= 1;
  472 | var isDragAccept = filesCount > 0 && allFilesAccepted(draggedFiles, this.props.accept);
  473 | var isDragReject = filesCount > 0 && (!isDragAccept || !isMultipleAllowed);
> 474 | return children({
      | ^  475 |   isDragActive: isDragActive,
  476 |   isDragAccept: isDragAccept,
  477 |   isDragReject: isDragReject,```

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:11
  • Comments:6

github_iconTop GitHub Comments

29reactions
rolandjitsucommented, Dec 16, 2018

@StefanoSega yes, that’s expected. You’re required to provide a child fn and apply at least the props from getRootProps() on the jsx element that your child fn returns. E.g.:

<Dropzone onDrop={acceptedFiles => console.log(acceptedFiles)}>
  {({getRootProps}) => (
    <div {...getRootProps()}>
      <p>Drop files here, or click to select files</p>
    </div>
  )}
</Dropzone>

@RosenTomov if you don’t share a repo or something I cannot help. All the examples at react-dropzone.js.org work as expected as far as I can tell.

11reactions
RosenTomovcommented, Dec 17, 2018

@rolandjitsu Ok, I’m sorry. Turns out that I had a second obscure Dropzone in my code, which was causing this.

After adding the properties, it works perfectly. Feel free to close the issue.

example with the Dropzone, I forgot about:

 // old
 <Dropzone
	onDrop={(accepted, rejected) => handleFileDrops(accepted, rejected)}
	multiple
	maxSize={8000000}	
	className={styles.uploadButton}
  />
  
  // new
  <Dropzone onDrop={handleFileDrops} multiple maxSize={8000000}>
	{({ getRootProps, getInputProps }) => (
	  <div
		{...getRootProps()}
		className={styles.uploadButton}
	  >
		<input {...getInputProps()} />
	  </div>
	)}
  </Dropzone>
Read more comments on GitHub >

github_iconTop Results From Across the Web

react-dropzone
Simple React hook to create a HTML5-compliant drag'n'drop zone for files. Documentation and examples at https://react-dropzone.js.org.
Read more >
Changelog | Finsemble
Fixed a bug where a React error was thrown by the Workspace Preferences tab. ... Finsemble Assimilation has been updated to Assimilation version...
Read more >
How to solve 'prop type error' for my react-dropzone app
I've tried to add a getRootprops() like it says to do in the docs but I'm still experiencing the breaking issue. Here's a...
Read more >
JavaScript Data Grid Migrate from 7.4 to 8.0 - Handsontable
This modification is a major rewrite of a core feature and may result in breaking changes in your application. General guidelines. Check if...
Read more >
Migration Guide | Cypress Documentation
Migrating to Cypress 12.0 This guide details the changes and how to ... errors since the errors are representative of the previous test....
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