paypal / paypal-js

Loading wrapper and TypeScript types for the PayPal JS SDK
Apache License 2.0
229 stars 78 forks source link

[Bug] Error: zoid destroyed all components - when using the messages component in dev mode #532

Open EvgenyPolyakov opened 2 months ago

EvgenyPolyakov commented 2 months ago

Library used

react-paypal-js

šŸž Describe the Bug

We recently updated our Nexjs project from v12.2 to v14.2.4 and encountered this error

console

This error appears every time we start the dev server and only when using the messages component in the provider options. When refreshing the page, the error no longer appears.

šŸ”¬ Minimal Reproduction

npx create-next-app@latest (Would you like to use App Router -> NO)

cd my-app

yarn add @paypal/react-paypal-js

Modify src/pages/_app.tsx

...
const options = {
    clientId: 'test',
    currency: 'EUR',
    components: 'messages',
};

export default function App({ Component, pageProps }: AppProps) {
    return (
        <PayPalScriptProvider options={options}>
            <Component {...pageProps} />
        </PayPalScriptProvider>
    );
}

yarn dev

Check console

šŸ˜• Actual Behavior

I noticed that when launching dev mode, the SDK downloads the paypal script 2 times, apparently this causes an error. When refreshing the page, the error no longer appears, apparently because the __paypal_storage__ key has been added to Local Storage. If the key is deleted, the error will occur again. In production, the script is also loaded 2 times, but no error occurs.

šŸ¤” Expected Behavior

No error in the console

šŸŒ Environment

jzstern commented 1 week ago

also experiencing this ā€” did you ever find a solution?