Closed vimode closed 2 years ago
Oh you mean because this means you can't enter spaces at all...hmm yeah I think onSubmit would be nicer if easy enough? Don't think it's too bad though if it is hard.
I agree it isn't very bad as spaces aren't a valid character in usernames on either of the websites. It just feels a little aggressive 😄
Let me try a few things. 🤔
Instead of using trim(), let me try using a regex pattern to replace the the whitespace with "", something like e.target.value.replace(/\s+/ig, "")
, if it has a little different and has a less aggressive behavior then that would be better.
If regex doesn't work then, I would use trim() onSubmit to instances of username
being passed, as it looks like username
is passed as an argument to onCheckUser
and getUserUrl
and nowhere else from this component.
I will get back to you as soon as I try these possible solutions, in the meantime if you have other ideas or suggestions or advice or tips I am open to all of those 😃
So the regex replace works the same as trim() if used with onChange.
So I used the trim while passing the state username
as an argument in the onSubmit function. Everything should work fine. 🤞
Thanks @vimode
Possible solution to fix #709
Do you think this solution is a little user hostile? Would it be better to apply the trim() method only onSubmit to all the usages of state
username
thereafter?Thank you.