您可以创建自己的PayPal Button组件。
class PayPalButton extends React.Component { constructor() { super(); // you can take this value from a config.js module for example. this.merchantId = '6XF3MPZBZV6HU'; } componentDidMount() { let container = this.props.id; let merchantId = this.merchantId; window.paypalCheckoutReady = function() { paypal.checkout.setup(merchantId, { locale: 'en_US', environment: 'sandbox', container: container, }); } } render() { return( <a id={this.props.id} href="/checkout" /> ); }}ReactDOM.render(<PayPalButton id="button" />, document.getElementById('View'));JSFiddle上的工作示例 。



