-
Notifications
You must be signed in to change notification settings - Fork 79
Added react-native-sdk docs #1622
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
Merged
+1,802
−0
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,106 @@ | ||
| --- | ||
| title: 'Components' | ||
| description: Reusable UI components for Flow interactions in React Native. | ||
| sidebar_position: 3 | ||
| --- | ||
|
|
||
| ## Connect | ||
|
|
||
| A drop-in wallet connection component that handles the entire authentication flow. When disconnected, it displays a "Connect Wallet" button. When connected, it shows the user's address and opens a Profile modal on press. | ||
|
|
||
| **Props:** | ||
|
|
||
| - `onConnect?: () => void` – Callback triggered after successful authentication | ||
| - `onDisconnect?: () => void` – Callback triggered after logout | ||
| - `balanceType?: "cadence" | "evm" | "combined"` – Specifies which balance to display (default: `"cadence"`) | ||
| - `"cadence"`: Shows the token balance from the Cadence side | ||
| - `"evm"`: Shows the token balance from the Flow EVM side | ||
| - `"combined"`: Shows the total combined token balance from both sides | ||
| - `balanceTokens?: TokenConfig[]` – Optional array of token configurations to display in the balance selector | ||
| - `modalEnabled?: boolean` – Whether to show the profile modal on press when connected (default: `true`) | ||
|
|
||
| **Basic Usage:** | ||
|
|
||
| The simplest way to add wallet connection to your app: | ||
|
|
||
| ```tsx | ||
| import { View, Text } from "react-native"; | ||
| import { Connect } from "@onflow/react-native-sdk"; | ||
|
|
||
| function WalletSection() { | ||
| return ( | ||
| <View> | ||
| <Text>Connect Wallet</Text> | ||
| <Text>Connect your Flow wallet to interact with the blockchain.</Text> | ||
| <Connect /> | ||
| </View> | ||
| ); | ||
| } | ||
| ``` | ||
|
|
||
| **With Callbacks:** | ||
|
|
||
| ```tsx | ||
| import { Connect } from "@onflow/react-native-sdk"; | ||
|
|
||
| <Connect | ||
| onConnect={() => console.log("Wallet connected!")} | ||
| onDisconnect={() => console.log("Wallet disconnected")} | ||
| /> | ||
| ``` | ||
|
|
||
| **With Balance Display:** | ||
|
|
||
| ```tsx | ||
| import { Connect } from "@onflow/react-native-sdk"; | ||
|
|
||
| <Connect | ||
| balanceType="combined" | ||
| balanceTokens={[ | ||
| { | ||
| symbol: "FLOW", | ||
| name: "Flow", | ||
| vaultIdentifier: "A.1654653399040a61.FlowToken.Vault", | ||
| }, | ||
| ]} | ||
| /> | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## Profile | ||
|
|
||
| A standalone component for displaying wallet information including account address and balance. Use this when you want to show user details separately from the Connect button. | ||
|
|
||
| **Props:** | ||
|
|
||
| - `onDisconnect?: () => void` – Callback triggered when the user presses the disconnect button | ||
| - `balanceType?: "cadence" | "evm" | "combined"` – Specifies which balance to display (default: `"cadence"`) | ||
| - `"cadence"`: Shows the token balance from the Cadence side | ||
| - `"evm"`: Shows the token balance from the Flow EVM side | ||
| - `"combined"`: Shows the total combined token balance from both sides | ||
| - `balanceTokens?: TokenConfig[]` – Optional array of token configurations to display in the balance selector | ||
|
|
||
| **Usage:** | ||
|
|
||
| ```tsx | ||
| import { View } from "react-native"; | ||
| import { Profile, useFlowCurrentUser } from "@onflow/react-native-sdk"; | ||
|
|
||
| function UserProfile() { | ||
| const { user } = useFlowCurrentUser(); | ||
|
|
||
| if (!user?.loggedIn) { | ||
| return null; | ||
| } | ||
|
|
||
| return ( | ||
| <View> | ||
| <Profile | ||
| balanceType="combined" | ||
| onDisconnect={() => console.log("User disconnected")} | ||
| /> | ||
| </View> | ||
| ); | ||
| } | ||
| ``` | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
"feel native to React Native development" is repetitive
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.
I would also add a note that this is built on the same hooks as the React SDK and link to that