walletconnect-monorepo icon indicating copy to clipboard operation
walletconnect-monorepo copied to clipboard

Can't get the QR modal to show after closing it once

Open Flawe opened this issue 3 years ago • 2 comments

If I run await provider.enable() but then close the modal so it trigger the promise error, running await provider.enable() a second time doesn't show the QR modal again (the promise never returns). What's the best way to reset the state so the QR modal shows every time provider.enable() is called if the modal is closed?

Flawe avatar Sep 17 '21 01:09 Flawe

Did you launch the app on a mobile device? When I do await provider.enable( ) it doesn't do anything. Can you perhaps share with me your code so far?

alona-daphna avatar Dec 23 '21 18:12 alona-daphna

I found a solution ( I don't know if it is the best way ) which is to capture when user close the modal with catch() and re create the provider object, this is an example code using react

const [myProvider, setMyProvider] = useState(
    new WalletConnectProvider({....... your settings   .......})
    )
const connectBTN = () => {
    myProvider
         .enable()
         .then(() => console.log("modal showed"))
         .catch((err) => {
            setMyProvider(
               new WalletConnectProvider({... your settings .... })
            );
         });
}

Wathekkhlifi avatar Jul 28 '22 16:07 Wathekkhlifi

Hey, is this still an issue? @Flawe @Wathekkhlifi?

finessevanes avatar Jan 10 '23 01:01 finessevanes