Skip to content
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

[react, react-native] Fix double connection issue, add ConnectEmbed component #2055

Merged
merged 27 commits into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .changeset/tidy-falcons-listen.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
"@thirdweb-dev/react-native": minor
"@thirdweb-dev/react-core": minor
"@thirdweb-dev/wallets": patch
"@thirdweb-dev/react": minor
---

- Fix double connection issue when Connecting a Safe / Smart Wallet. Now the personal wallet will not be set as the active wallet - only the final wallet will be set as the active wallet. This fixes the issue of hooks like `useWallet`, `useAddress`, `useConnectionStatus` etc showing the wrong wallet / address / connection status for a brief moment when connecting a Safe / Smart Wallet.

- Add `ConnectEmbed` component and `useShowConnectEmbed` hook to allow for embedding the ConnectWallet's Modal directly into the page.
- `useShowConnectEmbed` returns `true`` if the `<ConnectEmbed />`should be rendered. It returns`true`` if either one of the following conditions are met:

- the wallet is NOT connected
- the wallet IS connected but the user is NOT signed in and `auth` is required ( loginOptional is NOT set to false )

```tsx
function Example() {
const loginOptional = false;
const showConnectEmbed = useShowConnectEmbed(loginOptional);

if (!showConnectEmbed) {
return <div> Wallet is connected </div>;
}

return (
<ConnectEmbed
auth={{
loginOptional,
}}
/>
);
}
```

- Show "Disconnect Wallet" option in "Sign in" Screen and don't disconnect wallet instead of disconnecting the wallet when "Sign in" screen is dismissed by closing the modal. This makes this screen reusable for both ConnectWallet and ConnectEmbed components and also improves the user experience.
Loading
Loading