You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(next/image): improve error message when src={null} (#71398)
There is a React error that suggests the user change `src=""` to
`src={null}`.
> An empty string ("") was passed to the src attribute. This may cause
the browser to download the whole page again over the network. To fix
this, either do not render the element at all or pass null to src
instead of an empty string.
Even though `next/image` treats those both the same way, a user
attempting to use `src={null}` would cause the build to crash with a
confusing error message (JS only problem since TS would catch it much
earlier since src is a required prop).
```
⨯ TypeError: Cannot read properties of null (reading 'default')
at isStaticRequire (.next/server/chunks/ssr/node_modules__pnpm_1b81c1._.js:142:16)
at isStaticImport (.next/server/chunks/ssr/node_modules__pnpm_1b81c1._.js:148:40)
at getImgProps (.next/server/chunks/ssr/node_modules__pnpm_1b81c1._.js:320:9)
at .next/server/chunks/ssr/node_modules__pnpm_1b81c1._.js:2839:82
digest: "1613180311"
```
This PR ensures that `src={null}` will print the expected error that was
added back in a previous PR:
- #38847
0 commit comments