Skip to content

Controlled input's value ill responsive #25

Description

@Aditya81016

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)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions