fix(astro): accept single array child in unstyled buttons#8561
Conversation
Port the @clerk/react fix from #8556 to @clerk/astro so the same RSC server/client boundary case (custom child arriving as a one-item array) no longer trips the misleading "multiple children" error. Adds the first React component tests to the astro package covering the default child, a normal single custom child, and the array- wrapped single child regression case. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: 0ff14fc The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository YAML (base), Organization UI (inherited) Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThis PR fixes the Astro package's unstyled button components to accept a single React element passed as a one-item array. The Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
@clerk/astro
@clerk/backend
@clerk/chrome-extension
@clerk/clerk-js
@clerk/dev-cli
@clerk/expo
@clerk/expo-passkeys
@clerk/express
@clerk/fastify
@clerk/hono
@clerk/localizations
@clerk/nextjs
@clerk/nuxt
@clerk/react
@clerk/react-router
@clerk/shared
@clerk/tanstack-react-start
@clerk/testing
@clerk/ui
@clerk/upgrade
@clerk/vue
commit: |
Description
Ports the
@clerk/reactfix from #8556 to@clerk/astro. Astro carries its own duplicate copy ofassertSingleChild(marked// TODO-SHARED) that was not updated when the React-side fix landed.Same root cause as #8556: when a custom button child crosses a Next-style server/client boundary, React can deliver it as a one-item array.
React.Children.only()rejects that shape, which the SDK catches and surfaces as a misleading "multiple children" error to the user. The fix falls back toReact.Children.toArray()and accepts a length-1 array of a valid element, preserving the genuine multi-child error path.This benefits all seven astro unstyled buttons via the shared util:
SignInButton,SignUpButton,SignOutButton,SignInWithMetamaskButton,CheckoutButton,SubscriptionDetailsButton,PlanDetailsButton.Also adds the first React component tests to the astro package, mirroring the regression test from #8556 plus baseline coverage (default child, custom child, array-wrapped single child).
Checklist
pnpm testruns as expected. (21/21 in@clerk/astro, including 3 new tests.)pnpm buildruns as expected. (Full repo build not verified end-to-end — pre-existing failures in unrelated workspace packages, unrelated to this change.)clerk-docsPR Add example for multiple children on <SignUpButton>/<SignInButton> components clerk-docs#3358 already covers the multi-child guidance.Type of change
References
@clerk/reactfix this ports