mirror of
https://github.com/cloudflare/vinext.git
synced 2026-05-09 08:25:34 +02:00
[PR #1021] [MERGED] fix: add hydration-level onError replay in next/image via useLayoutEffect #1025
Labels
No labels
enhancement
enhancement
good first issue
help wanted
nextjs-tracking
nextjs-tracking
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/vinext#1025
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/cloudflare/vinext/pull/1021
Author: @Divkix
Created: 5/2/2026
Status: ✅ Merged
Merged: 5/2/2026
Merged by: @james-elicx
Base:
main← Head:fix/1007-next-image-hydration-onerror-replay📝 Commits (5)
c9a14aafix: add hydration-level onError replay in next/image via useLayoutEffect (#1007)39835c3fix: address PR review feedback for next/image onError hydration replay (#1007)770249cfix(next/image): address PR review — extract helper, clean deps, add comment2b5cbf5fix: guard onLoad replay with naturalWidth > 0, clean deps (#1007)a7ce561fix: port Next.js useMergedRef hook for next/image ref merging📊 Changes
3 files changed (+265 additions, -3 deletions)
View changed files
📝
packages/vinext/src/shims/image.tsx(+122 -3)➕
packages/vinext/src/shims/use-merged-ref.ts(+57 -0)📝
tests/shims.test.ts(+86 -0)📄 Description
Fixes #1007
Summary
useNonWarningLayoutEffect+img.src = img.srcto re-trigger the error trajectory when an image fails before React hydration completes (e.g. during SSR streaming or initial HTML parse)mergedRefto capture the underlying img element and forward the parent ref simultaneously@unpic/reactImage elements (supports ref forwarding)Test plan
tests/shims.test.tscovering onError, onLoad+onError, ref forwarding, and loader pathafterAlltimeout inpages-router.test.ts)🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.