Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

useField's onChange function should accept non-string values as args #3946

Open
JorensM opened this issue Jan 24, 2024 · 0 comments
Open

useField's onChange function should accept non-string values as args #3946

JorensM opened this issue Jan 24, 2024 · 0 comments

Comments

@JorensM
Copy link

JorensM commented Jan 24, 2024

Bug report

Current Behavior

Currently the useField()s onChange accepts either an event or a string. For inputs that are more complicated than simple strings, this won't suffice. For example if I want to have a field where the values are stored as an array, I won't be able to do that with the current type definitions for onChange

Expected behavior

I would expect the onChange to accept a value that is equal to the generic of useField. For example if I have useField<number[]>(), I'd expect the onChange to accept either an event or a value of type number[]

Suggested solution(s)

Change the onChange arg type definition to accept the generic that was passed to useField

Your environment

Software Version(s)
Formik 2.4.5
React 1.8.2
TypeScript 5.1.3
Browser Chrome
npm/Yarn Yarn
Operating System Windows 10
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

1 participant