react-dropzone / react-dropzone

Simple HTML5 drag-drop zone with React.js.
https://react-dropzone.js.org/
MIT License
10.56k stars 787 forks source link

I am using react-dropzone is my remote app & getting this error "useDropzone is not a function", while if i remove it from my vite config, project builds & runs successfully #1319

Open ubaidrajputtmetastaq opened 1 year ago

ubaidrajputtmetastaq commented 1 year ago

This is my Vite config file.

import { defineConfig } from "vite"; import react from "@vitejs/plugin-react"; import federation from "@originjs/vite-plugin-federation";

export default defineConfig({ plugins: [ react(), federation({ name: "remote", filename: "remoteEntry.js", exposes: { "./Storebuilder": "./src/builder", }, shared: [ "react", "react-dom", "axios", "immer", "react-beautiful-dnd", "react-dropzone", "react-hook-form", "react-modal", "zustand", ], }), ], build: { modulePreload: false, target: "esnext", minify: false, cssCodeSplit: false, }, });

Please see the error on my console with the attached image.

Screenshot 2023-09-18 at 1 27 31 PM

I am able to run my app if I remove "react-dropzone" from the shared config.

Please get back to me on this.

JClackett commented 10 months ago

Yeah, also have the exact same issue

omrirz commented 4 months ago

@JClackett @ubaidrajputtmetastaq try:

import * as reactDropzone from "react-dropzone"; const { useDropzone } = reactDropzone;

rolandjitsu commented 1 week ago

@omrirz thanks for the suggested fix. Do you know why is it behaving that way? Is it related to ESM?