Luehang / react-paypal-button-v2

An easy and simple to use React button component to implement PayPal Checkout with Smart Payment Buttons V2 (Version 2).
https://luehangs.site/lue_hang/projects/react-paypal-button-v2
MIT License
274 stars 81 forks source link

[BUG] PayPal Button shows duplicate, double buttons #126

Open OmerMessing opened 2 years ago

OmerMessing commented 2 years ago

To Do First

Software Package Version: v2.6.3

Describe the bug

I see the PayPal button double, I tried downgrading to react-paypal-button-v2@2.6.2 but I still see the same result. I tried moving the button in the page to different places in the code but it always shows double buttons.

The button is working but I also have this error in the console:

b.sbox.stats.paypal.com/v2/counter.cgi?p=uid_3890f557ca_mtu6mdc6nda&s=SMART_PAYMENT_BUTTONS:1 Failed to load resource: net::ERR_CONNECTION_REFUSED

To Reproduce

  1. Put the PayPalButton somewhere in your code with the required props and run the page on the browser.

Expected behavior

A single button is supposed to render.

Screenshots

Screen Shot 2022-05-23 at 18 21 42

Desktop (please complete the following information):

Additional context

DominicHulsey commented 2 years ago

I had this issue also OmerMessing, figured it out. Using strictMode causes duplicate render. disable this in app initialization. If you used create-react-app and typescript like I did, do this in App.tsx:

const root = ReactDOM.createRoot(
  document.getElementById("root") as HTMLElement
);
root.render(
  //remove this tag
  // <React.StrictMode>
    <App />
  // </React.StrictMode>
);
lmwenda commented 1 year ago

i got this as well i'm using nextjs

wangxingxing123654 commented 1 year ago

+1

nabilzouhir commented 1 year ago

If you're using NextJS go to next.config.js and set reactStrictMode: false