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.
Summary & motivation
Fix a bug where
elements
is not injected when using async Stripe and only mounting aCardCvcElement
orCardExpiry
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 afterElements
is instantiated which triggers a re-render on components wrapped withinject
.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 animplied*Type
. The newly registered Elements will not have anyimplied*Type
and will always be filtered out.This better fix would involve moving
_elements
tostate
. 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.