This repository was archived by the owner on Mar 27, 2021. It is now read-only.
register all elements #519
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary & motivation
Fix a bug where
elementsis not injected when using async Stripe and only mounting aCardCvcElementorCardExpiryElement.I fixed this by always registering all Elements. Previously, we skipped this for Elements that are not auto-detected. This change ensures that
stateis always updated afterElementsis 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
createTokenwe always filter by animplied*Type. The newly registered Elements will not have anyimplied*Typeand will always be filtered out.This better fix would involve moving
_elementstostate. 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.