Skip to content

v4.0.0

Choose a tag to compare

@cbala-stripe cbala-stripe released this 02 Sep 20:20
· 22 commits to master since this release
v4.0.0
fc16f86

Changed

  • [breaking] split out custom checkout imports (#609)
  • Update useCheckout to return loading/error states (#606)

Upgrade guidance

Import changes

Checkout paths changed:
Note: this only applies to Elements with Checkout Sessions API integrations.

import {useCheckout, PaymentElement} from '@stripe/react-stripe-js';

to

import {useCheckout, PaymentElement} from '@stripe/react-stripe-js/checkout';

useCheckout changes

Previously:

  • CheckoutProvider renders children if initCheckout succeeded, and null otherwise.
  • useCheckout() returns the SDK if initCheckout succeeded, and throws an error otherwise.

Now (>= v4.0.0):

  • CheckoutProvider renders children unconditionally.
  • useCheckout() returns a disjoint union describing the asynchronous state. The new return value now looks like:
type useCheckout = () =>
  | {type: 'loading'}
  | {
      type: 'success';
      checkout: CheckoutValue;
    }
  | {type: 'error'; error: {message: string}};