Open ryanrouleau opened 4 years ago
Switching the prop name from src
to something else like srcJpeg
makes it work 🙏 . Must be some conflict w/ the prop being named src
. I'm gonna leave this as open so you can take a look at it incase it's a symptom of something else, but feel free to close it if it's expected behavior.
Hi @ryanrouleau Thank you very much for the bug report. That is definitely not an expected behavior and may come from a bug in the babel plugin. I'll look into it.
So this is pretty strange.
I have a component that looks like:
components/common/FallbackImg.tsx
then I use it like:
pages/index.tsx
I get the error
However if I remove the require in the usage of
FallbackImg
and just pass undefined for example, it works fine (albeit the image is broken of course on the page since it's undefined).It also works fine if I define
FallbackImg
directly inpages/index.tsx
(with the require) and don't import it from somewhere else.Any idea why this would happen? Unfortunately
<Img />
doesn't fit our exact use case so we need something like the above.Thanks! And great work with this package it's fantastic 🥇
Edit: tested on a clean create-next-app and the same behavior occurs