The "Disappearing Zero": Handling Numeric Inputs in React Native Forms The article explains a common bug in React Native forms where entering the number zero causes the input field to clear itself, due to JavaScript treating `0` as a "falsy" value. The fix involves replacing the common but flawed pattern `value ? String(value) : ''` with an explicit null/undefined check: `value !== null && value !== undefined ? String(value) : ''`. This ensures zero is correctly displayed as a string and prevents validation errors from libraries like Zod or Yup. If you’ve spent any time building forms in React Native with React Hook Form and validation libraries like Zod or Yup , you’ve likely encountered a strange phenomenon: the "Disappearing Zero." One minute you're building a sleek checkout or progress flow, and the next, your users are complaining that every time they try to enter 0 , the input field just... wipes itself clean. The culprit? JavaScript’s definition of "falsy." The Trap: JavaScript Falsiness In React Native, numeric inputs often start as null or undefined or a number type in your state . Since TextInput or custom Input components expect a string , a common pattern is to cast the value like this: // ❌ The Buggy Way value={value ? String value : ''} On the surface, this looks clean. If there's a value, stringify it; otherwise, show an empty string. The Gotcha: In JavaScript, 0 is falsy. When a user types "0", the expression value ? ... evaluates to false , and the input receives an empty string '' . The zero vanishes instantly, leaving your users confused and your validation library potentially complaining about a missing value. The Solution: Explicit Checks To fix this, we need to stop relying on loose truthiness and start checking for what we actually care about: whether the value is null or undefined . // ✅ The Robust Way value={value == null && value == undefined ? String value : ''} By being explicit, we ensure that 0 which is not null or undefined is correctly stringified and rendered in the UI. Real-World Example: React Hook Form + Controller Here is how this looks in a typical implementation. In this example, we're tracking "Completed Stages," where 0 is a perfectly valid and common input.