anza-xyz / wallet-standard

Solana extensions to the Wallet Standard.
Apache License 2.0
82 stars 42 forks source link

Optimize standard wallet adapter wrapping #2

Closed jordaaash closed 1 year ago

jordaaash commented 1 year ago

The useStandardWalletAdapters hook is inefficient, triggering a render from useEffect on the initial render. This causes an app using this to initially render without the wrapped standard wallets, having a tendency to mess with logic that auto-selects a wallet. The filtering of the adapters provided is also inefficient, filtering standard adapters against each other by name, iterating over adapters too many times, and also causing later-registered wallets to end up in the output before first-registered ones. This fixes these things by using refs and memos and splitting the adapters into separate queues.