Refactor contingencyFlow zoid component to support JS SDK Reloads #51
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.
This PR fixes the "listener already exists" error when reloading the JS SDK when using hosted-fields (originally reported here: paypal/paypal-sdk-client#44).
The error is fixed by creating the zoid component in the setupHandler instead so it can be cleaned up in the
destroy()
hook to play nice with the setup/destroy workflow of the sdk-client.Additional Info
This PR refactors the zoid component to use the same memoize getter approach that the Buttons component uses. This makes it easy to reference the component in multiple places while only creating it once.
This PR breaks up the contingency flow component into two files. I made this change to make it easier to unit test and to follow the zoid folder pattern used in other repos. I learned that the testdouble.js library considers partial mocks an anti-pattern so having two files avoids the need to partially mock the subject.