Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove string cleaning from state-saved values. #1287

Merged
merged 2 commits into from
May 13, 2020

Conversation

Gnito
Copy link
Contributor

@Gnito Gnito commented May 12, 2020

This StripeBankAccountTokenInputField component is very old code (in a sense that there has been a lot of Stripe iteration and addition of new countries) - we should probably rewrite this component at some point. It's not even following our pretty old convention of naming Final Form field components as Field*.

This PR removes:

  • String cleaning for state-saved values.
    It is done only on code values (bank codes, routing numbers, account-number, etc.) sent to Stripe.

    I wonder if that formatted code was originally used for some error printing (i.e. sent values).

  • Removed errorsClearedFromInputs state handling after the async call was made.
    This was dead code and just caused saving of duplicate info to state.

const errorsClearedFromInputs = inputsNeeded.map(inputType => {
const input = prevState[inputType];
return { ...input, error: null };
});
Copy link
Contributor Author

@Gnito Gnito May 12, 2020

Choose a reason for hiding this comment

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

This code actually creates another set of input values to state - it's about array vs object: state[0] instead of overwriting state[inputType]. Reducer would easily solve this, but in the end, this is dead code - error clearing is done earlier.

@OtterleyW
Copy link
Contributor

LGTM! Remember to update the changelog

@Gnito Gnito merged commit 85002ab into master May 13, 2020
@Gnito Gnito deleted the remove-string-cleaning-from-state-values branch May 13, 2020 06:45
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.

2 participants