Skip to content

Commit

Permalink
Fix when loader = undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
styfle committed Apr 8, 2022
1 parent 37f8f17 commit 998b3af
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions packages/next/client/image.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -390,13 +390,15 @@ export default function Image({
}

let loader = defaultImageLoader as ImageLoader
if ('loader' in rest && rest.loader) {
const customImageLoader = rest.loader
loader = (obj) => {
// The config object is internal only so we must
// delete before invoking the user-defined loader()
delete obj.config
return customImageLoader(obj)
if ('loader' in rest) {
if (rest.loader) {
const customImageLoader = rest.loader
loader = (obj) => {
// The config object is internal only so we must
// delete before invoking the user-defined loader()
delete obj.config
return customImageLoader(obj)
}
}
// Remove property so it's not spread on <img>
delete rest.loader
Expand Down

0 comments on commit 998b3af

Please sign in to comment.