-
Notifications
You must be signed in to change notification settings - Fork 431
fix(expo): needs second factor failing to navigate on expo #7665
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(expo): needs second factor failing to navigate on expo #7665
Conversation
…cation in React Native navigation
Update the version of @clerk/clerk-js from major to patch and fix handling of missing window.location in React Native navigation.
Fixed crash in React Native when `window.location` is undefined during navigation, improving redirect-based flows.
🦋 Changeset detectedLatest commit: 6015884 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
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 |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
@clerk/agent-toolkit
@clerk/astro
@clerk/backend
@clerk/chrome-extension
@clerk/clerk-js
@clerk/dev-cli
@clerk/expo
@clerk/expo-passkeys
@clerk/express
@clerk/fastify
@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: |
📝 WalkthroughWalkthroughThis change adds React Native compatibility to the Clerk navigation system. A changeset entry documents the patch release, while the core implementation in 🚥 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. 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 |
Description
The fix that I have added is for the "needs second factor":
When signing in with password on a new/unrecognized device, Clerk's Client Trust feature returns needs_second_factor status. Clerk then tries to navigate to the second factor UI by calling its internal navigate() function.
The problem: navigate() in packages/clerk-js/src/core/clerk.ts does this:
let toURL = new URL(to, window.location.href);
In React Native:
Result: Crash with "Cannot read property 'href' of undefined"
We now check for the window location, and if it cant be found, we will replace the navigation with a router.push / router.replace because in React Native, there's no window.location, the router is the only way to navigate. The fix checks: if window.location is undefined, use the custom router. If no custom router was provided either, warn and bail out gracefully instead of crashing.
MOBILE-392: Evan Bacon - Expo SDK issues
Checklist
pnpm testruns as expected.pnpm buildruns as expected.Type of change
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.