andrewangelle / react-paypal-button

A button component to implement PayPal's Express Checkout in React
23 stars 9 forks source link

SSR Server side rendering error #3

Closed Distil62 closed 5 years ago

Distil62 commented 6 years ago

Hello,

When i try to render the button is SSR i have the error window is undefined

Temp fix :

class Paypal extends Component {

constructor(props) {
if (typeof window !== 'undefined') {
    PaypalButton = require('react-paypal-button');
}
}
}
Kaukov commented 5 years ago

This is an issue with Webpack and this has been known to be the hackfix for it. I don't think @andrewangelle can do anything about it since he's just abstracting on top of PayPal's button for easier use

andrewangelle commented 5 years ago

@Distil62 Yes, see Kaukov's reply above. You seem to have the right fix for it.

andrewangelle commented 5 years ago

Closing this for now. Feel free to open a new issue if anything changes.