Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Checkout: Modify useCreateExistingCards to only rememoize only when ids change #49057

Merged
merged 1 commit into from
Feb 1, 2021

Commits on Jan 20, 2021

  1. Modify useCreateExistingCards to only rememoize only when ids change

    The `useCreateExistingCards` hook creates composite-checkout payment
    method objects and has a dependency on an array of objects from the
    stored cards endpoint. Previously, the payment methods were recreated
    any time the stored cards array changed. Since the array is an object,
    this is an referential equality check.
    
    Here, we change the hook such that it will only recreate the payment
    methods if the ids of the stored cards change. Since the ids are numbers
    or strings, this is a primitive value check.
    
    This will make it easier to call the hook without recreating the payment
    methods each time since the stored card data typically comes from the
    `getStoredCards` selector which always returns a new array.
    sirbrillig committed Jan 20, 2021
    Configuration menu
    Copy the full SHA
    9304418 View commit details
    Browse the repository at this point in the history