Skip to content

Conversation

@awalker-stripe
Copy link
Contributor

Summary & motivation

Addresses #375: if un-mounting occurs on the same render as creating the element (ex. in strictmode), elements.create could get called multiple times without element.destroy being called. This was because setting our state with setElement doesn't apply to the next render, so the element would still be null and we wouldn't call to destroy.

This PR reverts part of #372 by switching back to a ref to track creating, updating, and destroying an element. However, it keeps the element state used to attach events in that PR.

Testing & documentation

  • Added unit test that fails in v1.16.3 for strict mode to make sure .create() and destroy() get called correctly
  • Tested against reproduction of the issue, where multiple re-renders using React 17 (not in strict mode) threw an error.
  • Storybooks for Payment and Card Element still both work

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