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
Element type is invalid error #554
Comments
I’m not sure what can cause this since we didn’t change anything on how the component is being exported or built. Can someone investigate that? |
Yeah we did here #510 |
@okonet I viewed the pull you linked but I have no idea how do I configure to avoid this error? |
Calling component with |
It’s hard to tell without looking at your code but looks like transpilation issue on your side with your Babel config. Please post how your babelrc looks like and how you import dropzone in your code. |
@okonet Hi all, thank u for collaborating on this fantastic component, i have a similar issue my app is isomorphic and when i try to render from server i have same issue because node does not interprets imports, maybe was a problem with building?. |
I think the problem is that it doesn’t get transpiled properly. You have to use umd build. Might be a problem with project’s webpack setup. |
worked for me |
I believe this was fixed when we fixed the webpack builds. Though I would like to see if any others are coming across this issue still. |
I digged a bit deeper, for me the problem was that I used ts-jest without For some reason, this worked with the normal webpack build, but not when using jest:
was compiled to: the extra [default] breaks it in this case, as this is undefined. I'll check my build config once more, but if someone stumbles over this issue it might be helpful. |
I have the same
This problem occurs immediately after I started using code splitting with Webpack. It affected a few other libraries such as as @mojadev said, using <Dropzone.default /> solves it (same thing with |
This issue seems to have broken dependant packages, like react-dropzone-s3-uploader. |
I have the same |
Not sure if this helps track this down, but if I run local, I need to use If I deploy to production (i.e., webpack), I need to render only |
@gtwilliams03 No, it isn't a good fix form me. I have client and server rendering. |
@kildem Not a good fix for me either, FWIW. I need to remember to swap |
@SourceCipher @kildem @okonet I fixed this issue by disabling module transformation by the Babel. I.e. in "presets": [
[
"env",
{
"modules": false
....
}
]
] |
I have the same issue using meteor and typescript. |
Same issue with Jest, Webpack, Electron and Typescript. Works fine in production, just Jest that seems to fail.
Using Changing to Will keep searching though - very useful package. |
Same issue for me. I can fix it by adding So for now this is my fix:
|
For me it was webpack's ModuleConcatenationPlugin that apparently removed __esModule definition in react-dropzone files in development mode. |
After trying several described methods, I ended up using: import * as Dropzone from 'react-dropzone/dist/index'; |
+1. If you're, like me, using create-react-app with Typescript, there's no way I can find around this problem. I can't even try any of the solutions above. :( |
Does anyone know what the root cause it and can PR the fix? |
@yebrahim I'm using Typings are now baked in this package, in case you use the ones from |
Thanks @rolandjitsu, that did work. |
For future googlers: that's what fixed it for me: |
I still have the same problem. But importing like this works: let Dropzone = require("react-dropzone")
if ("default" in Dropzone) {
Dropzone = Dropzone.default
} |
only this workaround worked for me. Im using ts-jest. I had "Element type is invalid: expected a string (for built-in components)" problem |
I was getting the same error but turns out it was not Dropzone. I'm using an old version of reactstrap and was using
The Thought it will be useful since it is the only result in the Google. |
Having the same issue here using Astro deployed on Netlify |
Do you want to request a feature or report a bug?
What is the current behavior?
It seems like the plugin not getting imported following the installation guidance
React.createElement: type should not be null, undefined, boolean, or number. It should be a string (for DOM elements) or a ReactClass (for composite components)
and
Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object.
What I have tried to fix the problem?
I have seen various possible ways to fix it but none of them worked. For example importing like
import { Dropzone } from 'react-dropzone'
instead of
import Dropzone from 'react-dropzone'
But that will not solve the problem.
The only way I made it work is by downgrading to version 4.1.3 as someone mentioned before, but thats no use as it has a major bug which crashes the browser as been reported in #549
Please mention other relevant information such as the browser version, Operating System and react-dropzone version.
The text was updated successfully, but these errors were encountered: