Skip to content
This repository has been archived by the owner on Mar 27, 2021. It is now read-only.

register all elements #519

Merged
merged 1 commit into from
Apr 21, 2020
Merged

register all elements #519

merged 1 commit into from
Apr 21, 2020

Conversation

dweedon-stripe
Copy link
Collaborator

@dweedon-stripe dweedon-stripe commented Apr 21, 2020

Summary & motivation

Fix a bug where elements is not injected when using async Stripe and only mounting a CardCvcElement or CardExpiry Element.

I fixed this by always registering all Elements. Previously, we skipped this for Elements that are not auto-detected. This change ensures that state is always updated after Elements is instantiated which triggers a re-render on components wrapped with inject.

Registering these Elements should not have any unintended consequences. When we look up Elements for auto-detection in methods like createToken we always filter by an implied*Type. The newly registered Elements will not have any implied*Type and will always be filtered out.

This better fix would involve moving _elements to state. This is a much larger change that seemed to have some potential downstream implications that I wanted to avoid.

Testing & documentation

I updated the unit tests and tested this manually using the async demo.

@dweedon-stripe dweedon-stripe force-pushed the register-all-elements branch from ee9d615 to ffb616a Compare April 21, 2020 16:55
Copy link
Contributor

@christopher-stripe christopher-stripe left a comment

Choose a reason for hiding this comment

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

Awesome

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants