Skip to content

Commit e61820e

Browse files
authoredOct 17, 2022
Fix typo and add comment to next/image SyntheticEvent (#41480)
- Fix typo - Add comment - Link back to react docs - Remove unnecessary variable
1 parent a75b323 commit e61820e

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed
 

‎packages/next/client/image.tsx

+5-3
Original file line numberDiff line numberDiff line change
@@ -268,11 +268,14 @@ function handleLoading(
268268
setBlurComplete(true)
269269
}
270270
if (onLoadRef?.current) {
271+
// Since we don't have the SyntheticEvent here,
272+
// we must create one with the same shape.
273+
// See https://reactjs.org/docs/events.html
271274
const event = new Event('load')
272275
Object.defineProperty(event, 'target', { writable: false, value: img })
273276
let prevented = false
274277
let stopped = false
275-
const sytheticEvent = {
278+
onLoadRef.current({
276279
...event,
277280
nativeEvent: event,
278281
currentTarget: img,
@@ -288,8 +291,7 @@ function handleLoading(
288291
stopped = true
289292
event.stopPropagation()
290293
},
291-
}
292-
onLoadRef.current(sytheticEvent)
294+
})
293295
}
294296
if (onLoadingCompleteRef?.current) {
295297
onLoadingCompleteRef.current(img)

0 commit comments

Comments
 (0)
Please sign in to comment.