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.

document is not defined

See original GitHub issue

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

  • [ x] I found a bug
  • I want to propose a feature

What is the current behavior? Version 10.0.0 cause a document undefined error with server side rendering.

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

  1. Enable application with SSR
  2. Use react-dropzone

What is the expected behavior? no undefined error

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

Most likely caused from changing /src/utils/index.js

from

export const supportMultiple =
  typeof document !== 'undefined' && document && document.createElement
    ? 'multiple' in document.createElement('input')
    : true

to

export const supportMultiple = 'multiple' in document.createElement('input')

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:17
  • Comments:19

github_iconTop GitHub Comments

1reaction
okonetcommented, Mar 14, 2019

🎉 This issue has been resolved in version 10.0.4 🎉

The release is available on:

Your semantic-release bot 📦🚀

1reaction
Yaxiancommented, Mar 14, 2019

@Chris533 , it helps me, thx. @Dakkers try this:

import dynamic from 'next/dynamic';
const Dropzone = dynamic(() => import('react-dropzone'), { ssr: false });

const App = () => {
    return (
       <Dropzone>
            {({ getRootProps, getInputProps }) => (
                <div {...getRootProps()} className={classes.dropzone}>
                  <input {...getInputProps()} />
                  <div className={classes.itemOutContainer}>
                    <div className={classes.itemContainer}>
                      <div className={cns(classes.item, classes.itemCreate)}>
                        uploading files
                      </div>
                    </div>
                  </div>
                </div>
            )}
       </Dropzone>
    );
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

ReferenceError: document is not defined in JavaScript
The "ReferenceError: document is not defined" error occurs for multiple reasons: ... The document relates to the document object which represents a web...
Read more >
ReferenceError: document is not defined (in plain JavaScript)
Explanation: The error is caused because NextJs renders the page in the server only and in the server document (document is used inside...
Read more >
How to fix ReferenceError: Document is not defined ... - Sabe.io
The most common reason for getting the reference error while on the browser is when you try to access the document object too...
Read more >
How to solve the document is not defined error - Flavio Copes
Here's how to fix the “referenceerror: document is not defined” error that you might have in Node.js or with a tool like Next.js....
Read more >
How To Fix ReferenceError document is not defined ... - Isotropic
If you are trying to use the document object and receiving a ReferenceError: document is not defined error then there is a good...
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