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

Pera fails if imported twice on the same page #156

Open
SebastienGllmt opened this issue Oct 5, 2023 · 0 comments
Open

Pera fails if imported twice on the same page #156

SebastienGllmt opened this issue Oct 5, 2023 · 0 comments

Comments

@SebastienGllmt
Copy link

For an application we're building, we're integrating two developer tools both which come with Pera built-in

However, this leads to the following error

image

Notably, it seems to be caused by this line of code here:

window.customElements.define("pera-wallet-connect-modal", PeraWalletConnectModal);

It looks like all the define calls in this function need to be wrapped with a check to see if they're already defined

if (!customElements.get('pera-wallet-connect-modal')) {
  customElements.define('pera-wallet-connect-modal', PeraWalletConnectModal);
}

This code runs twice because even just importing @perawallet/connect calls this code to define all the elements even if Pera is not explicitly used by the dApp as seen here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant