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

Add React Hook and Context to Simplify UX #1284

Merged
merged 19 commits into from
Feb 6, 2025
Merged

Add React Hook and Context to Simplify UX #1284

merged 19 commits into from
Feb 6, 2025

Conversation

matiasbenary
Copy link
Contributor

@matiasbenary matiasbenary commented Feb 2, 2025

This PR adds a Wallet Selector Context Provider (WalletSelectorProvider) and a React Hook (useWalletSelector) that simplify initializing the wallet selector and using it on React applications

Note: This PR only adds a new package, currently it shows 18 files changed only because it is based on add-new-api (#1276 )

@matiasbenary matiasbenary requested a review from gagdiez February 2, 2025 20:49
@gagdiez gagdiez changed the base branch from main to add_wallet_api February 3, 2025 09:58
@gagdiez gagdiez changed the base branch from add_wallet_api to dev February 3, 2025 09:59
@gagdiez gagdiez changed the title Add a new package UseWalletSelector Add React Hook and Context to Simplify UX Feb 3, 2025
gagdiez
gagdiez previously approved these changes Feb 3, 2025
@gagdiez
Copy link
Collaborator

gagdiez commented Feb 3, 2025

very excited about this simpler interface!

import '@near-wallet-selector/modal-ui/styles.css';
import { setupMyNearWallet } from '@near-wallet-selector/my-near-wallet';
import { setupMeteorWallet } from '@near-wallet-selector/meteor-wallet';
import { WalletSelectorProvider } from '@near-wallet-selector/react-hook';

const walletSelectorConfig = {
  network: "testnet",
  createAccessKeyFor: "hello.near-examples.testnet",
  modules: [
    setupMyNearWallet(),
    setupMeteorWallet(),
  ],
}

export default function App({ Component }) {
  return (
    <WalletSelectorProvider config={walletSelectorConfig}>
      <Component {...pageProps} />
    </WalletSelectorProvider>
  );
}

@gagdiez gagdiez self-requested a review February 5, 2025 21:21
@gagdiez gagdiez marked this pull request as ready for review February 5, 2025 21:21
@trechriron trechriron self-requested a review February 6, 2025 15:14
Copy link
Collaborator

@trechriron trechriron left a comment

Choose a reason for hiding this comment

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

Amazing

@trechriron trechriron merged commit 49da0a4 into dev Feb 6, 2025
9 checks passed
@trechriron trechriron deleted the react-hook branch February 6, 2025 15:56
@trechriron trechriron mentioned this pull request Feb 6, 2025
14 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Shipped 🚀
Development

Successfully merging this pull request may close these issues.

4 participants