cyrilwanner / next-optimized-images

🌅 next-optimized-images automatically optimizes images used in next.js projects (jpeg, png, svg, webp and gif).
MIT License
2.21k stars 93 forks source link

TypeError in Canary Img component #167

Open bezoerb opened 4 years ago

bezoerb commented 4 years ago

First of all, thanks for this module. I'm currently playing around with the Canary version and the corresponding react-optimized-image module.

<Img src={require(`publicImages/logo.png`)} webp sizes={[400, 800]} />

Throws an Error:

TypeError: Cannot read property 'fallback' of undefined
    at findFallbackImage (.../node_modules/react-optimized-image/lib/components/Img.js:71:14)

I already tried to debug but without the sources being public available this is a little challenging :) What about making the dependencies of the canary version public:

Thanks :)

brandonpittman commented 4 years ago

@bezoerb You probably forgot the babelrc settings.

cyrilwanner commented 4 years ago

I published a new canary version today which should recognize more use-cases (also styled-components) so I suggest trying that out. A missing babelrc setting could also lead to this error.

Those repositories were lacking documentation so that's why I kept them private. But that has now been resolved and all dependencies are now public.

bezoerb commented 4 years ago

Thanks @cyrilwanner i'm currently working on another project but i'll try the changes as soon as i get back to it :)