import React from "react"; import type { Components, CreateInstanceOptions, FindEligiblePaymentMethodsResponse, LoadCoreSdkScriptOptions } from "../types"; type PayPalProviderPropsBase = Omit, "components" | "clientToken" | "clientId"> & Omit & { components?: Components[]; eligibleMethodsResponse?: FindEligiblePaymentMethodsResponse; children: React.ReactNode; }; type PayPalProviderProps = (PayPalProviderPropsBase & { clientToken: string | Promise | undefined; clientId?: never; }) | (PayPalProviderPropsBase & { clientId: string | Promise | undefined; clientToken?: never; }); /** * {@link PayPalProvider} creates the SDK script, component scripts, runs eligibility, then * provides these in context to child components via the {@link usePayPal} hook. * * SDK loading is automatically deferred until clientToken or clientId is available. * Both can be either a string, Promise, or undefined. * * **Important:** When passing a Promise, you must ensure referential stability across renders. * An unstable Promise reference (e.g., calling `fetchClientToken()` or `fetchClientId()` inline) * will cause the SDK to re-initialize on every render. Wrap the promise in `useMemo` or store it in state. * * @example * // With string clientToken * * * * * @example * // With string clientId * * * * * @example * // With Promise clientToken (memoize to prevent re-fetching) * const tokenPromise = useMemo(() => fetchClientToken(), []); * * * * * * @example * // With Promise clientId * const clientIdPromise = useMemo(() => fetchClientId(), []); * * * * * * @example * // With deferred loading (clientToken) * const [clientToken, setClientToken] = useState(); * * useEffect(() => { * fetchClientToken().then(setClientToken); * }, []); * * * * * * @example * // With deferred loading (clientId) * const [clientId, setClientId] = useState(); * * useEffect(() => { * fetchClientId().then(setClientId); * }, []); * * * * * * @example * // Show custom loader while SDK initializes * function MyCheckout() { * const { loadingStatus } = usePayPal(); * const isPending = loadingStatus === INSTANCE_LOADING_STATE.PENDING; * * if (isPending) { * return
Loading PayPal SDK...
; * } * * return ; * } * * * * */ export declare const PayPalProvider: React.FC; export {};