amplify-ui
amplify-ui copied to clipboard
onChange event for TextField component is wrong type
This issue is related to the amplify-ui@next
for React.
The event passed as argument to the function should be something like ChangeEvent<HTMLInputElement>
, like it is in <PasswordField>
, but instead has any
(see screenshot below).
This means that when trying to access things like the value of the target (e.target.value
) TS won't compile unless I explicitly set the type in the signature of the event handler like:
onChange={(e: ChangeEvent<HTMLInputElement>) => { /*...*/ }}
Expected:
good catch! TextField
is a tricky component, as it can act as an input
or a textarea
depending on the value of the isMultiline
property. Will take a look and provide a fix to provide type-safety on event handlers.
@reesscot is working on splitting out TextArea
and TextField
. So this wrong type thing will be fixed by then
This will be fixed in our next major release.
This should be fixed @dreamorosi ! Please reopen if you are still having an issue.
This should be fixed by 4.x release now