-
Notifications
You must be signed in to change notification settings - Fork 39
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
issue: Example NumberField component can't get subsequently updated by the reset function if field is empty #92
Comments
I got it to work by changing the example function NumberField() {
const {
field: { value, onChange },
} = useTsController<number | string>();
return (
<div>
<input
type="number"
value={value ?? ""}
onChange={(e) => {
const val = e.target.valueAsNumber;
onChange(isNaN(val) ? "" : val);
}}
/>
</div>
);
} |
thanks for the repro, seems like the issue only happens when resetting from an empty field which is interesting. The difference with your above fix is that it's setting the form state to a string value, which is different from what the example number field does (it sets to a number instead of a string), which isn't going to validate correctly I don't think. I think I know what's causing this though |
Version Number
1.4.5
Codesandbox/Expo snack
https://codesandbox.io/s/cocky-driscoll-0bpr67?file=/src/App.tsx
Steps to reproduce
Expected behaviour
Number fields should keep getting updated beyond the first call to reset.
Relevant log output
No response
The text was updated successfully, but these errors were encountered: