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

EditCardDetails: Refactor to a functional component #35237

Merged
merged 1 commit into from
Aug 12, 2019

Conversation

sirbrillig
Copy link
Member

@sirbrillig sirbrillig commented Aug 8, 2019

Changes proposed in this Pull Request

In preparation to upgrade the EditCardDetails component to use Stripe Elements and Payment Intents (see previous work in #34848), this PR just reorganizes the component into a stateless functional component instead of a class.

There wasn't much present that required a class in the first place; there was no state, and I think the redirect-on-invalid behavior is actually easier to understand happening on every render than using the lifecycle methods.

Testing instructions

  1. Sandbox the store.
  2. Make sure you have purchased something, then visit http://calypso.localhost:3000/me/purchases, click on a purchase, and then click on "Change Payment Method"
  3. Fill out all the fields with a test card (eg: 4242424242424242) and submit the form. It will help to use a unique name for the cardholder name.
  4. Reload the resulting page (to force calypso to fetch the updated card data), then visit the purchase you updated again and click the "Payment method" text/icon.
  5. Be sure that the cardholder name shown is the same as the one you updated above.

@matticbot
Copy link
Contributor

@sirbrillig sirbrillig requested a review from a team August 8, 2019 18:43
@matticbot
Copy link
Contributor

Here is how your PR affects size of JS and CSS bundles shipped to the user's browser:

Sections (~22 bytes removed 📉 [gzipped])

name       parsed_size           gzip_size
purchases       -614 B  (-0.1%)      -22 B  (-0.0%)

Sections contain code specific for a given set of routes. Is downloaded and parsed only when a particular route is navigated to.

Legend

What is parsed and gzip size?

Parsed Size: Uncompressed size of the JS and CSS files. This much code needs to be parsed and stored in memory.
Gzip Size: Compressed size of the JS and CSS files. This much data needs to be downloaded over network.

Generated by performance advisor bot at iscalypsofastyet.com.

Copy link
Contributor

@yoavf yoavf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Looks good, tested well :)

@sirbrillig sirbrillig merged commit a9d8ee1 into master Aug 12, 2019
@sirbrillig sirbrillig deleted the update/edit-card-details-functional branch August 12, 2019 16:59
sirbrillig added a commit that referenced this pull request Aug 13, 2019
In preparation to upgrade the `AddCardDetails` component to use Stripe Elements and Payment Intents (see previous work in #34848), this PR just reorganizes the component into a stateless functional component instead of a class. Previously this was done for `EditCardDetails` in #35237 which is nearly identical to this component.

There wasn't much present that required a class in the first place; there was no state, and I think the redirect-on-invalid behavior is actually easier to understand happening on every render than using the lifecycle methods.
sirbrillig added a commit that referenced this pull request Aug 14, 2019
* AddCardDetails: Refactor as functional component

In preparation to upgrade the `AddCardDetails` component to use Stripe Elements and Payment Intents (see previous work in #34848), this PR just reorganizes the component into a stateless functional component instead of a class. Previously this was done for `EditCardDetails` in #35237 which is nearly identical to this component.

There wasn't much present that required a class in the first place; there was no state, and I think the redirect-on-invalid behavior is actually easier to understand happening on every render than using the lifecycle methods.

* Fix big errors

How did I miss these? Clearly I wasn't paying attention.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants