fix(expo): recreate Android recomposer after reattach#9143
Conversation
|
@D3OXY is attempting to deploy a commit to the Clerk Production Team on Vercel. A member of the Team first needs to authorize it. |
🦋 Changeset detectedLatest commit: 4149758 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 |
📝 WalkthroughWalkthroughThe Android Compose native view host now defers recomposer creation until window attachment, recreates recomposition after reattachment, disposes composition state during detachment, and cancels stale resources. A Changesets entry records a patch release for ChangesExpo Compose lifecycle
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested labels: Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
packages/expo/android/src/main/java/expo/modules/clerk/ClerkComposeNativeViewHost.kt (1)
27-27: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valuePrefer importing
kotlinx.coroutines.Job/SupervisorJobinstead of fully-qualifying inline.Fully-qualified references (
kotlinx.coroutines.Job,kotlinx.coroutines.SupervisorJob) are repeated across the field declaration andstartRecomposer(); importing them would improve readability.Also applies to: 46-46, 54-54, 62-63, 65-65
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/expo/android/src/main/java/expo/modules/clerk/ClerkComposeNativeViewHost.kt` at line 27, Replace the fully qualified kotlinx.coroutines.Job and kotlinx.coroutines.SupervisorJob references in ClerkComposeNativeViewHost, including recomposerJob and startRecomposer(), with imports at the top of the file. Preserve the existing coroutine behavior and declarations.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@packages/expo/android/src/main/java/expo/modules/clerk/ClerkComposeNativeViewHost.kt`:
- Around line 53-67: Update startRecomposer so recomposerJob references the Job
returned by the coroutine launched to run
newRecomposer.runRecomposeAndApplyChanges(), rather than the standalone
SupervisorJob in the scope context. Preserve the existing scope and recomposer
setup, while ensuring the isActive guard permits recovery after the
recomposition coroutine completes or fails.
- Around line 53-67: Update ClerkAuthNativeView and ClerkUserProfileNativeView
so onAttachedToWindow() invokes setupView(), matching ClerkUserButtonNativeView.
Preserve the existing OnViewDidUpdateProps behavior and ensure reattaching
without prop changes recreates the Compose content after the recomposer
restarts.
---
Nitpick comments:
In
`@packages/expo/android/src/main/java/expo/modules/clerk/ClerkComposeNativeViewHost.kt`:
- Line 27: Replace the fully qualified kotlinx.coroutines.Job and
kotlinx.coroutines.SupervisorJob references in ClerkComposeNativeViewHost,
including recomposerJob and startRecomposer(), with imports at the top of the
file. Preserve the existing coroutine behavior and declarations.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository YAML (base), Repository UI (inherited)
Review profile: CHILL
Plan: Pro Plus
Run ID: c8505747-f658-4f76-b111-5055c5f794dd
📒 Files selected for processing (2)
.changeset/fuzzy-lions-recompose.mdpackages/expo/android/src/main/java/expo/modules/clerk/ClerkComposeNativeViewHost.kt
Description
Fixes #9142
Android native Clerk views cancel their parent
Recomposerwhenever the host temporarily detaches from its window. React Navigation can later reattach the same native view, leaving Compose content bound to a canceled parent composition context.This change makes the shared Android host own the complete composition lifecycle:
setupView()ensures a live recomposer exists before setting Compose content, including when React Native Fabric updates props or measures content before window attachment;AuthView,UserButton, andUserProfileView;iOS is unchanged.
Validation
pnpm --filter @clerk/expo... buildpnpm --filter @clerk/expo test— 92 tests passedpnpm --filter @clerk/expo lint— no errorspnpm --filter @clerk/expo format:checkBUILD SUCCESSFULChecklist
pnpm testruns as expected; targeted Expo tests pass.pnpm buildruns as expected; filtered Expo dependency build passes.Type of change
Summary by CodeRabbit