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

onValueChange with function #429

Closed
osvaldokalvaitir opened this issue Jul 28, 2020 · 6 comments
Closed

onValueChange with function #429

osvaldokalvaitir opened this issue Jul 28, 2020 · 6 comments

Comments

@osvaldokalvaitir
Copy link

I have a function that calculates the balance due, so onValueChange I put this function, but in the initial state of the component it executes the function.

I tried using onChange, but it doesn't have floatValues, sometimes it does and sometimes 'undefined'.

How could I perform the calculation function only when the user changes the value and not the initial state of react using formik?

@alexandre033
Copy link

Hello, i have approximately the same problem. When the props value change the onValueChange is fired !! It creates infinite loop when an input update another input vice versa.

@kristotruu
Copy link

+1 Have same problem.

@s-yadav
Copy link
Owner

s-yadav commented Nov 22, 2020

Is the infinite loop issue still persist? A code snippet might help for this.

Plus we can start passing the source of onValueChange, whether it's caused by prop change or actual input change.

I think we can pass the source object as 2nd parameter to onValueChange. Something like.

{
   source: 'prop'|'event',
   event: eventObj, // only set when the source is event.
}

@puru0019
Copy link

puru0019 commented Nov 1, 2021

Is the infinite loop issue still persist? A code snippet might help for this.

Plus we can start passing the source of onValueChange, whether it's caused by prop change or actual input change.

I think we can pass the source object as 2nd parameter to onValueChange. Something like.

{
   source: 'prop'|'event',
   event: eventObj, // only set when the source is event.
}

@s-yadav
Can you give some example with code in some online editors like code sandbox?

@s-yadav
Copy link
Owner

s-yadav commented Nov 3, 2021

This 2nd argument thing is not added till now. But can be added.

@nikhil-varma
Copy link
Collaborator

nikhil-varma commented Nov 8, 2021

We have extended the onValueChange callback to allow sending source details ! Please try it out and let us know if you have any further questions. Closing this issue as of now
Release version v4.8.0

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

No branches or pull requests

6 participants