Skip to content
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

Default export not working with react 16 and Webpack 4 #639

Closed
1 of 2 tasks
bring2dip opened this issue Aug 12, 2018 · 2 comments
Closed
1 of 2 tasks

Default export not working with react 16 and Webpack 4 #639

bring2dip opened this issue Aug 12, 2018 · 2 comments

Comments

@bring2dip
Copy link

bring2dip commented Aug 12, 2018

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?

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

This is because the Dropzone is imported as {default: function} which is an object.

import Dropzone from 'react-dropzone'
//not working
<Dropzone />

//working
<Dropzone.default />

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

What is the expected behavior?

If this is a feature request, what is motivation or use case for changing the behavior?

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

React version: 16.4.2
Dropzone version: 4.3.0
Webpack version: 4.16.5

Webpack mentions this in their migration guide
esm and non esm import

@bring2dip bring2dip changed the title Default export not working with react 16 Default export not working with react 16 and Webpack 4 Aug 12, 2018
@loopmode
Copy link

loopmode commented Aug 13, 2018

I don't think this is a react-dropzone issue, but rather an issue with webpack 4 or your specific setup..

I just tried out with react@16.4.2, react-dropzone@4.3.0 and webpack@3.8.1 (create-react-app), and it works just fine.
Also, the code does a perfectly normal export default and it's up to the consumer or env to interpret it correctly.

About the linked change in webpack behaviour: I think that's about import() as a function, and not about import as a statement.
(import('react-dropzone').then(({default: Dropzone}) => { ... }) or const {default: Dropzone} = await import('react-dropzone');

@Nodman
Copy link
Collaborator

Nodman commented Aug 13, 2018

Please see #554

@Nodman Nodman closed this as completed Aug 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants