Skip to content

walletInfos memo invalidated on every render with inline wallets array #5

@satoshai-dev

Description

@satoshai-dev

Problem

When consumers pass an inline array to the wallets prop:

<StacksWalletProvider wallets={['xverse', 'leather']}>

A new array reference is created on every render, which defeats the useMemo dependency check for walletInfos. This causes getStacksWallets() (which queries the DOM for installed extensions) to run on every render unnecessarily.

Fix

Either:

  • Document that wallets should be defined outside the component or wrapped in useMemo
  • Accept and compare by value internally (e.g., serialize to a string key for the memo dep)

Context

Identified during code review of PR #2.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions