-
Notifications
You must be signed in to change notification settings - Fork 133
Improved wc redirect flexibility and ConnectModal #2774
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- | ||
| "@onflow/fcl-react-native": minor | ||
| "@onflow/react-native-sdk": minor | ||
| --- | ||
|
|
||
| Improved wc redirect flexibility and updated connect modal to be normal centered modal for better layout support. |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -30,6 +30,23 @@ const defaultQueryOptions: DefaultOptions = { | |||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| // 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, | ||||||||||||||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
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, | |
| }) | |
| } | |
| // Create a stable key from all config inputs to detect if config actually changed | |
| return JSON.stringify({ | |
| cfg, | |
| flowJson, | |
| }) | |
| } | |
| } |
Copilot
AI
Dec 18, 2025
There was a problem hiding this comment.
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.
| // 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> | |
| >() |
There was a problem hiding this comment.
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.