Wallet rendering twice? #66
-
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Hello @ignaciolarranaga! It usually happens when the render method got called multiple times. Do you have special condition such as API calls inside useEffects, for example? One suggestion is to wait for those conditions to get satisfied before you allow the Wallet Button to render. If possible, feel free to provide more details so we can help you debug this issue. |
Beta Was this translation helpful? Give feedback.
-
Thanks @icaldana. I found the problem. I'm using NextJS so I can not really import the library directly (because of this: #52). I tried the suggestion here: #52 (reply in thread) but the initMercadoPago loaded dynamically interferes with the wallet rendering triggering the re-render causing the buttons to duplicate. I tried moving the initMercadoPago away from the wallet rendering but the "dynamic approach" ultimately causes the same interference. The best solution I was able to find was to load the library dynamically, then run the initialization and create the component.
|
Beta Was this translation helpful? Give feedback.
Thanks @icaldana. I found the problem.
I'm using NextJS so I can not really import the library directly (because of this: #52). I tried the suggestion here: #52 (reply in thread) but the initMercadoPago loaded dynamically interferes with the wallet rendering triggering the re-render causing the buttons to duplicate. I tried moving the initMercadoPago away from the wallet rendering but the "dynamic approach" ultimately causes the same interference.
The best solution I was able to find was to load the library dynamically, then run the initialization and create the component.
Sharing in case useful: