Perf improvements and billing updates

This commit is contained in:
giancarlo
2024-03-26 16:49:11 +08:00
parent 8626ea30c7
commit 4032aed827
39 changed files with 1261 additions and 1090 deletions

View File

@@ -15,10 +15,22 @@ export function EmbeddedCheckout(
provider: BillingProvider;
onClose?: () => void;
}>,
) {
return (
<LazyCheckout onClose={props.onClose} checkoutToken={props.checkoutToken} />
);
}
function LazyCheckout(
props: React.PropsWithChildren<{
checkoutToken: string;
provider: BillingProvider;
onClose?: () => void;
}>,
) {
const CheckoutComponent = useMemo(
() => memo(loadCheckoutComponent(props.provider)),
[],
[props.provider],
);
return (
@@ -69,7 +81,7 @@ function buildLazyComponent<
) {
let LoadedComponent: ReturnType<typeof lazy> | null = null;
const LazyComponent = forwardRef((props, ref) => {
const LazyComponent = forwardRef(function LazyDynamicComponent(props, ref) {
if (!LoadedComponent) {
LoadedComponent = lazy(load);
}