All files / app/customer CheckoutButton.tsx

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47  11x                   11x 11x   8x 8x 8x 8x 8x   8x                 11x   1x 1x 1x   1x     11x 10x   10x       11x  
import { CustomerInitializeOptions, CustomerRequestOptions } from '@bigcommerce/checkout-sdk';
import React, { PureComponent } from 'react';
 
export interface CheckoutButtonProps {
    containerId: string;
    methodId: string;
    deinitialize(options: CustomerRequestOptions): void;
    initialize(options: CustomerInitializeOptions): void;
    onError?(error: Error): void;
}
 
export default class CheckoutButton extends PureComponent<CheckoutButtonProps> {
    componentDidMount() {
        const {
            containerId,
            initialize,
            methodId,
            onError,
        } = this.props;
 
        initialize({
            methodId,
            [methodId]: {
                container: containerId,
                onError,
            },
        });
    }
 
    componentWillUnmount() {
        const {
            deinitialize,
            methodId,
        } = this.props;
 
        deinitialize({ methodId });
    }
 
    render() {
        const { containerId } = this.props;
 
        return (
            <div id={ containerId } />
        );
    }
}