coinbase / react-coinbase-commerce

Coinbase Commerce React
Apache License 2.0
92 stars 57 forks source link

React -Element type is invalid on production #111

Closed Shoyayeb closed 1 year ago

Shoyayeb commented 1 year ago

I'm using react latest version and "react-coinbase-commerce": "^1.6.0"

imported the react component as the documentation said import CoinbaseCommerceButton from 'react-coinbase-commerce';

now I got this error in my production: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object. I think it has something to do with the component export.

As said in this #55 issue, it should be fixed by version 1.5.1.

Shoyayeb commented 1 year ago

I've got it fixed by creating another component and importing it in place of the CoinbaseCommerceButton component. I think it was a problem with rollupjs that vite uses for production build.

import CoinbaseCommerceButton from 'react-coinbase-commerce';

export const Switch = CoinbaseCommerceButton.default
  ? CoinbaseCommerceButton.default
  : CoinbaseCommerceButton;