-
Notifications
You must be signed in to change notification settings - Fork 110
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
Named export 'LazyLoadImage' not found. The requested module 'react-lazy-load-image-component' is a CommonJS module, which may not support all module.exports as named expo rts. #121
Comments
import pkg from 'react-lazy-load-image-component'; This will temporary solve this problem |
not correct, i tried many times, probably the problem is in production at astro, i used another library to fix it |
i am using react remix and it seems like working fine. |
Does not work for me, images do not load anymore |
Okay, it works for prerendering but if I run "npm run dev", it does show any images anymore, only works with prerendering for me |
如何解决? |
Please use another library |
Did find the one? |
The same error occurred when I deployed to Vercel |
with vite remix plugin:
🤷♂️ |
Is it working now? I am using react for astro and it show the same error message |
used another library to fix it |
U can use react-lazy-load interface ZuImageProps extends ImgHTMLAttributes { const ZuImage = ({placeholderZuLazy, alt, width, height, fallback = '/assets/images/loading-266.svg', src, ...props}: ZuImageProps) => {
) |
Vite has stricter handling for CommonJS modules, so you can fix this by using dynamic imports:
|
import { LazyLoadImage } from 'react-lazy-load-image-component';
^^^^^^^^^^^^^
SyntaxError: Named export 'LazyLoadImage' not found. The requested module 'react-lazy-load-image-component' is a CommonJS module, which may not support all module.exports as named expo
rts.
CommonJS modules can always be imported via the default export, for example using:
import pkg from 'react-lazy-load-image-component';
const { LazyLoadImage } = pkg;
The text was updated successfully, but these errors were encountered: