Source: Inside client/assets/InputGroup.tsx in InputGroup() > handleInput() when calling setInputValue(value)
Context:
~ The value variable is meant to store the value of input element it returns and is updated via setValue() function each time the input element is updated (React controlled input).
~ The setInputValue() is a prop which updates the respective input value in parent component (our hack to pass value to parent component from child component) and the passed value in parent component is used for authentication
Issue: Even tho the setValue(target.value) method is called before the setInputValue(value) method, the value variable contains last value of the input element's value and not the the latest value.
for eg: if the input elements's value is " Adi " the value of value variable will be " Ad " and
now if you update input element's value to " Adit " the value of value variable will be " Adi "
But since the input element is a controlled element then both value variable and it should have same value.
So my theory by far is that the setValue(target.value) method do updates the value variable but a bit late and in that span of time while value still has the last input setInputValue(value) method is called
Conventions: If my theory is right then a setTimeout with a timer of about 200 should fix it but i don't think we should approach that solution since it wont be a garantee each time and would depend on user's pc's processing speed.
Work around: changed setInputValue(value) to setInputValue(target.value)
Source: Inside
client/assets/InputGroup.tsxinInputGroup() > handleInput()when callingsetInputValue(value)Context:
~ The
valuevariable is meant to store the value of input element it returns and is updated viasetValue()function each time the input element is updated (React controlled input).~ The
setInputValue()is a prop which updates the respective input value in parent component (our hack to pass value to parent component from child component) and the passed value in parent component is used for authenticationIssue: Even tho the
setValue(target.value)method is called before thesetInputValue(value)method, thevaluevariable contains last value of the input element's value and not the the latest value.for eg: if the input elements's value is " Adi " the value of
valuevariable will be " Ad " andnow if you update input element's value to " Adit " the value of
valuevariable will be " Adi "But since the input element is a controlled element then both
valuevariable and it should have same value.So my theory by far is that the
setValue(target.value)method do updates thevaluevariable but a bit late and in that span of time whilevaluestill has the last inputsetInputValue(value)method is calledConventions: If my theory is right then a setTimeout with a timer of about 200 should fix it but i don't think we should approach that solution since it wont be a garantee each time and would depend on user's pc's processing speed.
Work around: changed
setInputValue(value)tosetInputValue(target.value)