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

file_upload_with_preview__WEBPACK_IMPORTED_MODULE_4__.FileUploadWithPreview is not a constructor #67

Closed
dennohpeter opened this issue Nov 11, 2022 · 4 comments

Comments

@dennohpeter
Copy link

Hello @johndatserakis ,
I am getting this error Uncaught TypeError: file_upload_with_preview__WEBPACK_IMPORTED_MODULE_4__.FileUploadWithPreview is not a constructor in ReactJs v18.2.0

"file-upload-with-preview": "^5.0.8",

Here is my sample code

import "file-upload-with-preview/dist/file-upload-with-preview.min.css";
import { FileUploadWithPreview } from "file-upload-with-preview";

import React, { useState } from "react";

function Gallery() {

  if (typeof window !== "undefined") {
    const upload = new FileUploadWithPreview("file-upload", {
      multiple: true,
    });
  }

  return (
    <div
    class="custom-file-container"
    data-upload-id="file-upload"
  ></div>
    );

}
@dennohpeter
Copy link
Author

image

@johndatserakis
Copy link
Owner

Hey there, sorry for the issue and the delay responding. I will look into this ASAP.

I'm not sure what is causing your issue - but here's a link to a working TypeScript codepen that imports file-upload-with-preview the general way, and it is working correctly. Maybe something can jump out at us.

@nyancodeid
Copy link

nyancodeid commented Dec 10, 2022

I just imported like this, and it works now

import { FileUploadWithPreview } from 'file-upload-with-preview/dist/file-upload-with-preview.esm';

@johndatserakis
Copy link
Owner

Hey there - sorry for the trouble. I just went through and updated the package.json's exports property to be aligned with the modern expectations. To get the latest export type, use v6.0.2. You should no longer have to import from 'file-upload-with-preview/dist/file-upload-with-preview.esm'.

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