Skip to content

Conversation

@mfbz
Copy link
Contributor

@mfbz mfbz commented Dec 18, 2025

Improved wc redirect flexibility and updated connect modal to be normal centered modal for better layout support.

@mfbz mfbz requested a review from a team as a code owner December 18, 2025 00:33
@changeset-bot
Copy link

changeset-bot bot commented Dec 18, 2025

🦋 Changeset detected

Latest commit: df636ae

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@onflow/fcl-react-native Minor
@onflow/react-native-sdk Major

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

@vercel
Copy link

vercel bot commented Dec 18, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
react-sdk-demo Ready Ready Preview, Comment Dec 18, 2025 0:43am

@github-actions
Copy link
Contributor

github-actions bot commented Dec 18, 2025

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves WalletConnect redirect handling and updates the ConnectModal component to use a centered modal layout instead of a bottom sheet design. The changes add flexibility for apps to intercept WalletConnect redirects and provide better layout support across different screen sizes.

Key Changes:

  • Introduced singleton caching for flowClient to preserve auth state across component remounts
  • Changed WalletConnect redirect path from root to wc-redirect for better interception control
  • Replaced bottom sheet modal animation with centered modal design

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
packages/react-native-sdk/src/provider/FlowProvider.tsx Added singleton caching logic to preserve flowClient across remounts and prevent auth state loss
packages/react-native-sdk/README.md Added documentation section explaining WalletConnect deeplink path and Expo Router integration
packages/fcl-react-native/src/walletconnect/client.ts Updated redirect URI to use wc-redirect path instead of root path
packages/fcl-react-native/src/utils/react-native/ConnectModal.js Refactored modal from bottom sheet with custom animations to centered modal with fade animation
packages/fcl-react-native/README.md Added WalletConnect deeplink documentation
.changeset/pretty-walls-live.md Added changeset file documenting the changes

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +33 to +49
// Singleton to preserve flowClient across remounts (e.g., deeplink navigation)
// This prevents auth state from being lost when expo-router causes remounts
let cachedFlowClient: ReturnType<typeof createFlowClient> | null = null
let cachedConfigKey: string | null = null

function getConfigKey(
cfg: FlowConfig,
flowJson?: Record<string, unknown>
): string {
// Create a stable key from config to detect if config actually changed
return JSON.stringify({
accessNodeUrl: cfg.accessNodeUrl,
flowNetwork: cfg.flowNetwork,
walletconnectProjectId: cfg.walletconnectProjectId,
})
}

Copy link

Copilot AI Dec 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Module-level singletons can cause issues in environments where multiple instances of FlowProvider might be mounted simultaneously (e.g., in testing, multi-window apps, or server-side rendering). Consider using React context or a WeakMap keyed by config to manage instances safely.

Suggested change
// Singleton to preserve flowClient across remounts (e.g., deeplink navigation)
// This prevents auth state from being lost when expo-router causes remounts
let cachedFlowClient: ReturnType<typeof createFlowClient> | null = null
let cachedConfigKey: string | null = null
function getConfigKey(
cfg: FlowConfig,
flowJson?: Record<string, unknown>
): string {
// Create a stable key from config to detect if config actually changed
return JSON.stringify({
accessNodeUrl: cfg.accessNodeUrl,
flowNetwork: cfg.flowNetwork,
walletconnectProjectId: cfg.walletconnectProjectId,
})
}
// Cache Flow clients per FlowConfig to preserve auth state across remounts
// while avoiding a single global singleton shared across all FlowProvider instances.
const flowClientCache = new WeakMap<
FlowConfig,
ReturnType<typeof createFlowClient>
>()

Copilot uses AI. Check for mistakes.
Comment on lines +42 to +48
// Create a stable key from config to detect if config actually changed
return JSON.stringify({
accessNodeUrl: cfg.accessNodeUrl,
flowNetwork: cfg.flowNetwork,
walletconnectProjectId: cfg.walletconnectProjectId,
})
}
Copy link

Copilot AI Dec 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The config key only includes three properties, but createFlowClient uses many more properties (discoveryWallet, discoveryWalletMethod, flowJson, etc.). If any of these other properties change, the cached client will be incorrectly reused with stale configuration.

Suggested change
// Create a stable key from config to detect if config actually changed
return JSON.stringify({
accessNodeUrl: cfg.accessNodeUrl,
flowNetwork: cfg.flowNetwork,
walletconnectProjectId: cfg.walletconnectProjectId,
})
}
// Create a stable key from all config inputs to detect if config actually changed
return JSON.stringify({
cfg,
flowJson,
})
}
}

Copilot uses AI. Check for mistakes.
@@ -1,8 +1,8 @@
import {Image} from "expo-image"
import {createElement, useEffect, useRef, useState} from "react"
import {createElement, useEffect, useState} from "react"
Copy link

Copilot AI Dec 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The unused import 'useRef' was removed, but 'Animated' is also no longer used after removing the animation logic and should be removed from the imports as well.

Suggested change
import {createElement, useEffect, useState} from "react"
import {createElement} from "react"

Copilot uses AI. Check for mistakes.
@mfbz mfbz merged commit d8cbe12 into master Dec 18, 2025
8 checks passed
@mfbz mfbz deleted the mfbz/fix-apk-redirect branch December 18, 2025 09:24
@github-actions github-actions bot mentioned this pull request Dec 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants