Validation not triggering onBlur in React Native environment #2162
Describe the bug#
This is an issue I’ve encountered since my first use of TanStack Form in React Native, but I initially considered it trivial and ignored it.
In React Native, when validating with onChange, validation is triggered for all fields when handleSubmit is pressed, regardless of whether the inputs were touched or focused. The same behavior occurs with onSubmit validation.
However, with onBlur validation, pressing handleSubmit without interacting with any input does not trigger validation errors. The form also does not submit, which is expected since validation errors exist, but no errors are displayed to the user.
The onBlur validation only triggers after at least one input has been focused and then blurred (for example, by dismissing the keyboard).
I created a simple but realistic reproduction to demonstrate the issue. https://github.com/mdnjohn/tsform-rn-issue
Your minimal, reproducible example#
GitHub repo
Steps to reproduce#
- Clone the repo https://github.com/mdnjohn/tsform-rn-issue
- Install dependencies
- Run "bunx expo prebuild"
- Run "bun run android" and the form is present, just press "Submit" to see the validation not triggering
https://github.com/user-attachments/assets/f5131c0e-5efa-451e-8ad4-4d7c70e826a4
Expected behavior#
The expected behavior is that validation errors should be triggered and displayed on submit, regardless of whether the user has focused any input fields.
Currently, when using onBlur validation in React Native, submitting the form without interacting with any input prevents the form from submitting, which indicates that the form correctly detects validation errors internally. However, no validation errors are visually displayed to the user until at least one field has been focused and blurred.
How often does this bug happen?#
Every time
Screenshots or Videos#
https://github.com/user-attachments/assets/efe53c9f-fa42-40c8-a39b-d658939a61ea
Platform#
OS: Android
TanStack Form adapter#
react-form
TanStack Form version#
1.29.1
TypeScript version#
5.9.2
Additional context#
No response
This is an issue I’ve encountered since my first use of TanStack Form in React Native, but I initially considered it trivial and ignored it.
That's super unfortunate, I'm really sorry to hear this! I thought we'd had better support for RN than this.
Let me try to address this ASAP in the coming days.
Thanks
I cannot reproduce this behavior when pulling your demo into an Expo codebase. I even added an Expo template to our monorepo so we can reproduce any potential RN issues:
https://github.com/TanStack/form/pull/2167
In fact, I cannot reproduce this ticket on your own reproduction when using
npm iinstead ofbun install.I'd be VERY surprised if this did end up being a TanStack Form bug because of this. As such, I'm going to close this ticket.
That said, I know a lot about React Native and might be able to help find the upstream issue. What version of Android are you running into this? Is this on a real device or emulator?
crutchcorn(GitHub profile, opens in a new tab) closed this
I cannot reproduce this behavior when pulling your demo into an Expo codebase. I even added an Expo template to our monorepo so we can reproduce any potential RN issues:
https://github.com/TanStack/form/pull/2167
In fact, I cannot reproduce this ticket on your own reproduction when using
npm iinstead ofbun install.I'd be VERY surprised if this did end up being a TanStack Form bug because of this. As such, I'm going to close this ticket.
That said, I know a lot about React Native and might be able to help find the upstream issue. What version of Android are you running into this? Is this on a real device or emulator?
I understand, no problem at all. Since it never actually blocked me from using the library, I ended up working around it in the startup I’m building by switching the validation mode to onChange, and everything has been working perfectly ever since.
Honestly, the library is so good that using it almost feels like a natural law of the universe — there’s very little to complain about. Looking back at my implementation, I realized I was displaying the invalid state only when a field was both touched and invalid, so that may very well explain the behavior I was seeing.
Either way, thank you for taking the time to look into this. I genuinely can’t express enough respect for the work being done on these libraries. The level of quality, thoughtfulness, and developer experience is seriously admirable. Absolute respect .
Appreciate the kind words. Still sorry you're facing this. Let me know if you'd like me to dive deeper on my end — I'd just need to know what device/Android version you're using. Thanks for using our project!
Appreciate the kind words. Still sorry you're facing this. Let me know if you'd like me to dive deeper on my end — I'd just need to know what device/Android version you're using. Thanks for using our project!
No problem at all. As for the device info, the demo was running on pixel 3 running android 9 in android studio. The physical device i used for testing is a samsung a35
Sign in to join this conversation.
That's super unfortunate, I'm really sorry to hear this! I thought we'd had better support for RN than this.
Let me try to address this ASAP in the coming days.