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

form.setFieldValue based on previous value #5696

Merged
merged 3 commits into from Feb 9, 2024

Conversation

twiddler
Copy link
Contributor

@twiddler twiddler commented Feb 1, 2024

Hey everyone! 👋

I would like to set the value of a field foo based on the value it currently has. This is currently possible by using

form.setValues(prev => ({ foo: prev.foo + 1 }))

but (to the best of my knowledge) not by something like

form.setFieldValue("foo", prev => prev + 1)

I thought I'd give it a shot to make this a proper pull request, but I am facing type issues in the test I added:

Parameter 'prev' implicitly has an 'any' type. ts(7006)

I would really appreciate if someone could take it from here. Thanks! 🙏

@rtivital
Copy link
Member

rtivital commented Feb 1, 2024

Please fix test errors

@twiddler
Copy link
Contributor Author

twiddler commented Feb 1, 2024

I ran npm run prettier:write to fix the prettier errors. The type error that now shows is the one that I do not know how to solve. I'd appreciate any help. 🙏

@twiddler twiddler marked this pull request as ready for review February 2, 2024 12:11
@twiddler
Copy link
Contributor Author

twiddler commented Feb 2, 2024

Thanks @Pr0gramWizard! 🙏

@rtivital rtivital merged commit 158d54c into mantinedev:master Feb 9, 2024
1 check passed
@rtivital
Copy link
Member

rtivital commented Feb 9, 2024

Thanks!

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.

None yet

3 participants