Skip to content

Commit 11cab49

Browse files
HM-23-HMautofix-ci[bot]LeCarbonator
authored
docs(form): Fix grammar issues in the guides (TanStack#1965)
* docs(form): Fix grammar issues in the guides * docs(form): Fix grammar issues in the guides * ci: apply automated fixes and generate docs * Update docs/framework/react/guides/devtools.md Co-authored-by: LeCarbonator <18158911+LeCarbonator@users.noreply.github.com> * Update docs/framework/react/guides/dynamic-validation.md Co-authored-by: LeCarbonator <18158911+LeCarbonator@users.noreply.github.com> * Removed duplicates from validation.md --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: LeCarbonator <18158911+LeCarbonator@users.noreply.github.com>
1 parent 6877c23 commit 11cab49

File tree

9 files changed

+56
-57
lines changed

9 files changed

+56
-57
lines changed

docs/framework/react/guides/custom-errors.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ title: Custom Errors
55

66
TanStack Form provides complete flexibility in the types of error values you can return from validators. String errors are the most common and easy to work with, but the library allows you to return any type of value from your validators.
77

8-
As a general rule, any truthy value is considered as an error and will mark the form or field as invalid, while falsy values (`false`, `undefined`, `null`, etc..) mean there is no error, the form or field is valid.
8+
As a general rule, any truthy value is considered an error and will mark the form or field as invalid, while falsy values (`false`, `undefined`, `null`, etc.) mean there is no error, and the form or field is valid.
99

1010
## Return String Values from Forms
1111

@@ -133,7 +133,7 @@ Display in UI:
133133
}
134134
```
135135

136-
in the example above it depends on the event error you want to display.
136+
In the example above, the rendered message, code and styling depend on the event error you want to display.
137137

138138
### Arrays
139139

@@ -171,7 +171,7 @@ Display in UI:
171171

172172
## The `disableErrorFlat` Prop on Fields
173173

174-
By default, TanStack Form flattens errors from all validation sources (onChange, onBlur, onSubmit) into a single `errors` array. The `disableErrorFlat` prop preserves the error sources:
174+
By default, TanStack Form flattens errors from all validation sources (`onChange`, `onBlur`, `onSubmit`) into a single `errors` array. The `disableErrorFlat` prop preserves the error sources:
175175

176176
```tsx
177177
<form.Field

docs/framework/react/guides/devtools.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@ id: devtools
33
title: Devtools
44
---
55

6-
TanStack Form comes with a ready to go suit of devtools.
6+
TanStack Form comes with a ready-to-go suite of devtools.
77

88
## Setup
99

10-
Install the [TanStack Devtools](https://tanstack.com/devtools/latest/docs/quick-start) library and the [TanStack Form plugin](http://npmjs.com/package/@tanstack/react-form-devtools), from the framework adapter that your working in (in this case `@tanstack/react-devtools`, and `@tanstack/react-form-devtools`).
10+
Install the [TanStack Devtools](https://tanstack.com/devtools/latest/docs/quick-start) library and the [TanStack Form plugin](http://npmjs.com/package/@tanstack/react-form-devtools), from the framework adapter that you're working in (in this case `@tanstack/react-devtools` and `@tanstack/react-form-devtools`).
1111

1212
```bash
1313
npm i @tanstack/react-devtools
1414
npm i @tanstack/react-form-devtools
1515
```
1616

17-
Next in the root of your application import the `TanStackDevtools`.
17+
Next, in the root of your application, import the `TanStackDevtools`.
1818

1919
```tsx
2020
import { TanStackDevtools } from '@tanstack/react-devtools'
@@ -47,6 +47,6 @@ createRoot(document.getElementById('root')!).render(
4747
)
4848
```
4949

50-
Finally add any additional configuration you desire to the `TanStackDevtools` component, more information can be found under the [TanStack Devtools Configuration](https://tanstack.com/devtools/) section.
50+
Finally, add any additional configuration you desire to the `TanStackDevtools` component. More information can be found under the [TanStack Devtools Configuration](https://tanstack.com/devtools/) section.
5151

5252
A complete working example can be found in our [examples section](https://tanstack.com/form/latest/docs/framework/react/examples/devtools).

docs/framework/react/guides/dynamic-validation.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ id: dynamic-validation
33
title: Dynamic Validation
44
---
55

6-
In many cases, you want to change the validation rules based depending on the state of the form or other conditions. The most popular
6+
In many cases, you want to change the validation rules depending on the state of the form or other conditions. The most popular
77
example of this is when you want to validate a field differently based on whether the user has submitted the form for the first time or not.
88

99
We support this through our `onDynamic` validation function.
@@ -18,7 +18,7 @@ const form = useForm({
1818
firstName: '',
1919
lastName: '',
2020
},
21-
// If this is omitted, onDynamic will not be called
21+
// If this is omitted, `onDynamic` will not be called
2222
validationLogic: revalidateLogic(),
2323
validators: {
2424
onDynamic: ({ value }) => {
@@ -31,11 +31,12 @@ const form = useForm({
3131
})
3232
```
3333

34-
> By default `onDynamic` is not called, so you need to pass `revalidateLogic()` to the `validationLogic` option of `useForm`.
34+
> [!IMPORTANT]
35+
> By default, `onDynamic` is not called; therefore you must pass `revalidateLogic()` to the `validationLogic` option of `useForm`.
3536
3637
## Revalidation Options
3738

38-
`revalidateLogic` allows you to specify when validation should be run and change the validation rules dynamically based on the current submission state of the form.
39+
`revalidateLogic` allows you to specify when validation should be run and to change the validation rules dynamically based on the current submission state of the form.
3940

4041
It takes two arguments:
4142

@@ -64,7 +65,7 @@ const form = useForm({
6465

6566
## Accessing Errors
6667

67-
Just as you might access errors from an `onChange` or `onBlur` validation, you can access the errors from the `onDynamic` validation function using the `form.state.errorMap` object.
68+
Just as you might access errors from an `onChange` or `onBlur` validation, you can access errors from the `onDynamic` validation function using the `form.state.errorMap` object.
6869

6970
```tsx
7071
function App() {
@@ -177,7 +178,7 @@ function App() {
177178

178179
### Async Validation
179180

180-
Async validation can also be used with `onDynamic` just like with other validation logic. You can even debounce the async validation to avoid excessive calls.
181+
Async validation can also be used with `onDynamicAsync` just like with other validation logic. You can even debounce the async validation to avoid excessive calls.
181182

182183
```tsx
183184
const form = useForm({

docs/framework/react/guides/form-composition.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ id: form-composition
33
title: Form Composition
44
---
55

6-
A common criticism of TanStack Form is its verbosity out-of-the-box. While this _can_ be useful for educational purposes - helping enforce understanding our APIs - it's not ideal in production use cases.
6+
A common criticism of TanStack Form is that it is verbose out-of-the-box. While this verbosity _can_ be useful for educational purposes - helping to enforce understanding of our APIs - it's not ideal in production use cases.
77

88
As a result, while `form.Field` enables the most powerful and flexible usage of TanStack Form, we provide APIs that wrap it and make your application code less verbose.
99

@@ -103,7 +103,7 @@ function App() {
103103
}
104104
```
105105

106-
This not only allows you to reuse the UI of your shared component, but retains the type-safety you'd expect from TanStack Form: Typo `name` and get a TypeScript error.
106+
This not only allows you to reuse the UI of your shared component, but retains the type-safety you'd expect from TanStack Form: Mistyping `name` will result in a TypeScript error.
107107

108108
#### A note on performance
109109

@@ -162,7 +162,7 @@ function App() {
162162

163163
## Breaking big forms into smaller pieces
164164

165-
Sometimes forms get very large; it's just how it goes sometimes. While TanStack Form supports large forms well, it's never fun to work with hundreds or thousands of lines of code long files.
165+
Sometimes forms get very large; it's just how it goes sometimes. While TanStack Form supports large forms well, it's never fun to work with hundreds or thousands of lines of code in single files.
166166

167167
To solve this, we support breaking forms into smaller pieces using the `withForm` higher-order component.
168168

docs/framework/react/guides/linked-fields.md

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,19 @@ id: linked-fields
33
title: Link Two Form Fields Together
44
---
55

6-
You may find yourself needing to link two fields together; when one is validated as another field's value has changed.
7-
One such usage is when you have both a `password` and `confirm_password` field,
8-
where you want to `confirm_password` to error out when `password`'s value does not match;
9-
regardless of which field triggered the value change.
6+
You may find yourself needing to link two fields together, such that one is validated when another's value has changed.
7+
One such use case is when you have both a `password` and a `confirm_password` field.
8+
Here, you want the `confirm_password` field to error out if its value doesn't match that of the `password` field, regardless of which field triggered the value change.
109

11-
Imagine the following userflow:
10+
Imagine the following user flow:
1211

13-
- User updates confirm password field.
14-
- User updates the non-confirm password field.
12+
- User updates the `confirm_password` field.
13+
- User updates the `password` field.
1514

16-
In this example, the form will still have errors present,
17-
as the "confirm password" field validation has not been re-ran to mark as accepted.
15+
In this example, the form will still have errors present because the `confirm_password` field's validation has not been re-run to mark the field as valid.
1816

19-
To solve this, we need to make sure that the "confirm password" validation is re-run when the password field is updated.
20-
To do this, you can add a `onChangeListenTo` property to the `confirm_password` field.
17+
To solve this, you need to make sure that the `confirm_password` field's validation is re-run when the `password` field is updated.
18+
To do this, you can add an `onChangeListenTo` prop to the `confirm_password` field.
2119

2220
```tsx
2321
function App() {
@@ -74,4 +72,4 @@ function App() {
7472
}
7573
```
7674

77-
This similarly works with `onBlurListenTo` property, which will re-run the validation when the field is blurred.
75+
This is similar to the `onBlurListenTo` prop, which re-runs the validation when the linked field is blurred.

docs/framework/react/guides/listeners.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Imagine the following user flow:
1111
- User then selects a province from another drop-down.
1212
- User changes the selected country to a different one.
1313

14-
In this example, when the user changes the country, the selected province needs to be reset as it's no longer valid. With the listener API, we can subscribe to the onChange event and dispatch a reset to the field "province" when the listener is fired.
14+
In this example, when the user changes the country, the selected province needs to be reset as it's no longer valid. With the listener API, we can subscribe to the `onChange` event and dispatch a reset to the "province" field when the listener is fired.
1515

1616
Events that can be "listened" to are:
1717

@@ -94,7 +94,7 @@ We enable an easy method for debouncing your listeners by adding a `onChangeDebo
9494

9595
At a higher level, listeners are also available at the form level, allowing you access to the `onMount` and `onSubmit` events, and having `onChange` and `onBlur` propagated to all the form's children. Form-level listeners can also be debounced in the same way as previously discussed.
9696

97-
`onMount` and `onSubmit` listeners have to following props:
97+
`onMount` and `onSubmit` listeners have the following parameters:
9898

9999
- `formApi`
100100

docs/framework/react/guides/reactivity.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ id: reactivity
33
title: Reactivity
44
---
55

6-
Tanstack Form doesn't cause re-renders when interacting with the form. So you might find yourself trying to use a form or field state value without success.
6+
Tanstack Form doesn't cause re-renders when interacting with the form. So, you might find yourself trying to use a form or field state value without success.
77

88
If you would like to access reactive values, you will need to subscribe to them using one of two methods: `useStore` or the `form.Subscribe` component.
99

@@ -13,7 +13,7 @@ Some uses for these subscriptions are rendering up-to-date field values, determi
1313
1414
## useStore
1515

16-
The `useStore` hook is perfect when you need to access form values within the logic of your component. `useStore` takes two parameters. First, the form store. Second a selector to fine tune the piece of the form you wish to subscribe to.
16+
The `useStore` hook is perfect when you need to access form values within the logic of your component. `useStore` takes two parameters. First, the form store. Second, a selector to specify the piece of the form you wish to subscribe to.
1717

1818
```tsx
1919
const firstName = useStore(form.store, (state) => state.values.firstName)
@@ -28,7 +28,7 @@ While it IS possible to omit the selector, resist the urge as omitting it would
2828

2929
## form.Subscribe
3030

31-
The `form.Subscribe` component is best suited when you need to react to something within the UI of your component. For example, showing or hiding ui based on the value of a form field.
31+
The `form.Subscribe` component is best suited when you need to react to something within the UI of your component. For example, showing or hiding UI based on the value of a form field.
3232

3333
```tsx
3434
<form.Subscribe
@@ -49,4 +49,4 @@ The `form.Subscribe` component is best suited when you need to react to somethin
4949

5050
> The `form.Subscribe` component doesn't trigger component-level re-renders. Anytime the value subscribed to changes, only the `form.Subscribe` component re-renders.
5151
52-
The choice between whether to use `useStore` or `form.Subscribe` mainly boils down to that if it's rendered in the ui, reach for `form.Subscribe` for its optimizations perks, and if you need the reactivity within the logic, then `useStore` is the choice to make.
52+
The choice between whether to use `useStore` or `form.Subscribe` mainly boils down to your use case. If you're aiming for direct UI updates based on form state, use `form.Subscribe` for its optimization perks. And if you need the reactivity within the logic, then `useStore` is the better choice.

docs/framework/react/guides/submission-handling.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ title: Submission handling
55

66
## Passing additional data to submission handling
77

8-
You may have multiple types of submission behaviour, for example, going back to another page or staying on the form.
8+
You may have multiple types of submission behaviour, for example, going back to the previous page or staying on the form.
99
You can accomplish this by specifying the `onSubmitMeta` property. This meta data will be passed to the `onSubmit` function.
1010

1111
> Note: if `form.handleSubmit()` is called without metadata, it will use the provided default.

0 commit comments

Comments
 (0)