Skip to content
Source
Sign inSign up
TanStack/form
Open History to see the last commit

debugging.md

43 lines2.1 KB

1---
2id: debugging
3title: Debugging React Usage
4---
5​
6Here's a list of common errors you might see in the console and how to fix them.
7​
8## Changing an uncontrolled input to be controlled
9​
10If you see this error in the console:
11​
12```
13Warning: A component is changing an uncontrolled input to be controlled. This is likely caused by the value changing from undefined to a defined value, which should not happen. Decide between using a controlled or uncontrolled input element for the lifetime of the component. More info: https://reactjs.org/link/controlled-components
14```
15​
16It's likely you forgot the `defaultValues` in your `useForm` Hook or `form.Field` component usage. This is occurring
17because the input is being rendered before the form value is initialized and is therefore changing from `undefined` to `""` when a text input is made.
18​
19## Field value is of type `unknown`
20​
21If you're using `form.Field` and, upon inspecting the value of `field.state.value`, you see that the value of a field is of type `unknown`, it's likely that your form's type was too large for us to safely evaluate.
22​
23This typically is a sign that you should break down your form into smaller forms or use a more specific type for your form.
24​
25A workaround to this problem is to cast `field.state.value` using TypeScript's `as` keyword:
26​
27```tsx
28const value = field.state.value as string
29```
30​
31## `Type instantiation is excessively deep and possibly infinite`
32​
33If you see this error in the console when running `tsc`:
34​
35```
36Type instantiation is excessively deep and possibly infinite
37```
38​
39You've run into a bug that we didn't catch in our type definitions. While we've done our best to make sure our types are as accurate as possible, there are some edge cases where TypeScript struggled with the complexity of our types.
40​
41Please [report this issue to us on GitHub](https://github.com/TanStack/form/issues) so we can fix it. Just make sure to include a minimal reproduction so that we're able to help you debug.
42​
43> Keep in mind that this error is a TypeScript error and not a runtime error. This means that your code will still run on the user's machine as expected.