-
Notifications
You must be signed in to change notification settings - Fork 93
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
[Canary] Img: passing src from prop breaks component - babel plugin not installed/recognized #186
Comments
Yeah, it happens on my end as well. I wanted to make a LazyLoaded Component which wraps the Img component provided by the react-optimized-image package and adds some lazy loading functionality but... no luck so far. @cyrilwanner any thoughts about that? |
Yes, I am afraid that this (wrapping & looping) is not possible with the current canary version. But I will try supporting that use case. @stoil If you design your component with a similar API like <LazyLoad>
<Img src={require('./image.jpg')} />
</LazyLoad> But as written above, I'll try to support normal wrapping as well, it's just not yet in the current canary version. |
@cyrilwanner It worked on v5. I was pretty happy with that release. Reinstalled on a different machine and it all broke again. 😢 |
@brandonpittman which part worked on v5 (I guess you mean canary-5)? The issues mentioned here shouldn't have worked in any canary version 😅 |
@brandonpittman Maybe it's an unrelated bug, but I was using a loop to render images with a dynamic ref: https://github.com/brandonpittman/next-blog/blob/master/src/components/media_card.js |
@cyrilwanner hey! What do you think about this dynamic loading issue? Because right now, it isn't working for ex. when rendering blogposts. I'm happy to contribute if it isn't resolved wight now, and if you can help me with any idea, where should I look for this bug. |
Would like to contribute on this too, not experienced with babel so if you can tell us your thoughts it might gives us a headstart on solving this problem @cyrilwanner |
Related to cyrilwanner/react-optimized-image#6. |
Fixed it by adding Example: const foo = require(`../../public/assets/blog/${src}`);
<Img
src={foo}
rawSrc={{
fallback: {
original: {
1: require(`../../public/assets/blog/${src}?url`),
},
},
}}/>
I think the issue is, that https://github.com/cyrilwanner/react-optimized-image/blob/e27a012211bcf8d916007933d241de926f1158e2/src/plugin/transform/img.ts#L200 will not be called while compiling. |
The following works for me on latest canary:
however if i want to wrap it in another component and feed it a src
this breaks with the following message.
Babel plugin 'react-optimized-image/plugin' not installed or this component could not be recognized by it.
So it looks like i can not wrap the component, ok not that big of a deal.
But if I want to do something like this:
Now it is a problem, i can not loop the Img component, is this not possible with this component or am i doing something wrong?
The text was updated successfully, but these errors were encountered: