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.

Cannot import Dropzone using Typescript

See original GitHub issue

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

  • I found a bug

What is the current behavior? When I have the line import Dropzone from 'react-dropzone'; at the top of my file in typescript I’m unable to compile with the following error:

ERROR in [at-loader] ./src/client/components/uploader.tsx:2:8 TS1192: Module '"/Users/ashokraju/src/sc/caas-app/node_modules/@types/react-dropzone/index"' has no default export.

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

  1. Add line import Dropzone from 'react-dropzone'; to top of React component file.
  2. Try to compile the file.
  3. Get the above error.

What is the expected behavior? Should be able to compile.

In believe this is an issue with the type definitions?

Issue Analytics

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

github_iconTop GitHub Comments

7reactions
Lexaniuscommented, Oct 20, 2017

@oyvindym This solution works for me only with version 4.1.3

maybe "module": "dist/es/index.js", let the type file not working but it is only my opinion.

See: https://github.com/react-dropzone/react-dropzone/compare/v4.1.3...v4.2.1

7reactions
oyvindymcommented, Oct 20, 2017

Got the exact same bug.

Also, if I import Dropzone using import * as Dropzone from 'react-dropzone'; I get the following error when mounting the component:

invariant.js:42 Uncaught Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object.

Using following package versions:

{
    "@types/react": "16.0.14",
    "@types/react-dom": "16.0.1",
    "@types/react-dropzone": "4.1.0",
    "react": "16.0.0",
    "react-dom": "16.0.0",
    "react-dropzone": "4.2.1",
    "typescript": "2.5.3",
    ...
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Module not found: Error: Can't resolve 'dropzone'
In order to use the DropZone type in my typescript code, I first installed it using npm install --save-dev @types/dropzone .
Read more >
react-dropzone - npm
Start using react-dropzone in your project by running `npm i ... TypeScript icon, indicating that this package has built-in type ...
Read more >
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 >
Create a drag-and-drop with react-dropzone - LogRocket Blog
To create a drag-and-drop component with react-dropzone , all we need to do is copy and paste the snippets in our App.js file:...
Read more >
Create a Drag-and-Drop zone in React with react-dropzone
Right now, our code should be looking something like this in our App.js component. import React from "react"; function App() { return <div></div>;...
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