mirror of
https://github.com/cloudflare/vinext.git
synced 2026-05-09 08:25:34 +02:00
[PR #223] [MERGED] fix: resolve conditional React Hook calls in Link and Script shims #401
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#401
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/223
Author: @haddoumounir
Created: 3/2/2026
Status: ✅ Merged
Merged: 3/3/2026
Merged by: @southpolesteve
Base:
main← Head:fix/rules-of-hooks-conditional-calls📝 Commits (2)
341e76afix: resolve conditional React Hook calls in Link and Script shimsbd82431fix: skip prefetch setup for dangerous href schemes📊 Changes
2 files changed (+38 additions, -32 deletions)
View changed files
📝
packages/vinext/src/shims/link.tsx(+21 -14)📝
packages/vinext/src/shims/script.tsx(+17 -18)📄 Description
Summary
useState,useRef,useEffect,useCallback,useMemo), making them conditional. Moved the check to a boolean flag before hooks and the early return to after all hooks.typeof window === "undefined") was beforeuseEffect, making it conditional. MoveduseEffectbefore the SSR check since it never runs during SSR anyway.Test plan
<Link>(e.g.javascript:hrefs render inert<a>)<Script>SSR rendering still works forbeforeInteractivestrategy🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.