All files / app/checkout renderCheckout.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 411x 1x   1x             1x 4x 4x 4x   4x       4x       4x 1x   1x         4x                  
import React from 'react';
import ReactDOM from 'react-dom';
 
import { configurePublicPath } from '../common/bundler';
 
import { CheckoutAppProps } from './CheckoutApp';
 
export type RenderCheckoutOptions = CheckoutAppProps;
export type RenderCheckout = typeof renderCheckout;
 
export default function renderCheckout({
    containerId,
    publicPath,
    ...props
}: RenderCheckoutOptions): void {
    const configuredPublicPath = configurePublicPath(publicPath);
 
    // We want to use `require` here because we want to set up the public path
    // first before importing the app component and its dependencies.
    const { default: CheckoutApp } = require('./CheckoutApp');
 
    // We want to use `require` here because we only want to import the package
    // in development mode.
    if (process.env.NODE_ENV === 'development') {
        const whyDidYouRender = require('@welldone-software/why-did-you-render');
 
        whyDidYouRender(React, {
            collapseGroups: true,
        });
    }
 
    ReactDOM.render(
        <CheckoutApp
            containerId={ containerId }
            publicPath={ configuredPublicPath }
            { ...props }
        />,
        document.getElementById(containerId)
    );
}