Skip to content

Commit c8a45f1

Browse files
authored
Merge pull request #3 from TanStack/main
merge upstream edits
2 parents 9094f6b + ba32b7f commit c8a45f1

File tree

123 files changed

+2477
-709
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

123 files changed

+2477
-709
lines changed

.changeset/eight-dolls-wash.md

Lines changed: 0 additions & 7 deletions
This file was deleted.

.changeset/green-tips-do.md

Lines changed: 0 additions & 6 deletions
This file was deleted.

.github/workflows/autofix.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,6 @@ jobs:
3535
if: ${{ github.event_name == 'push' || github.event.inputs.generate-docs == true }}
3636
run: pnpm generate-docs
3737
- name: Apply fixes
38-
uses: autofix-ci/action@635ffb0c9798bd160680f18fd73371e355b85f27
38+
uses: autofix-ci/action@7a166d7532b277f34e16238930461bf77f9d7ed8
3939
with:
4040
commit-message: 'ci: apply automated fixes and generate docs'

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

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,61 @@ const ChildForm = withForm({
248248
})
249249
```
250250

251+
### Context as a last resort
252+
253+
There are cases where passing `form` with `withForm` is not feasible. You may encounter it with components that don't
254+
allow you to change their props.
255+
256+
For example, consider the following TanStack Router usage:
257+
258+
```ts
259+
function RouteComponent() {
260+
const form = useAppForm({...formOptions, /* ... */ })
261+
// <Outlet /> cannot be customized or receive additional props
262+
return <Outlet />
263+
}
264+
```
265+
266+
In edge cases like this, a context-based fallback is available to access the form instance.
267+
268+
```ts
269+
const { useAppForm, useTypedAppFormContext } = createFormHook({
270+
fieldContext,
271+
formContext,
272+
fieldComponents: {},
273+
formComponents: {},
274+
})
275+
```
276+
277+
> [!IMPORTANT] Type safety
278+
> This mechanism exists solely to bridge integration constraints and should be avoided whenever `withForm` is possible.
279+
> Context will not warn you when the types do not align. You risk runtime errors with this implementation.
280+
281+
Usage:
282+
283+
```tsx
284+
// sharedOpts.ts
285+
const formOpts = formOptions({
286+
/* ... */
287+
})
288+
289+
function ParentComponent() {
290+
const form = useAppForm({ ...formOptions /* ... */ })
291+
292+
return (
293+
<form.AppForm>
294+
<ChildComponent />
295+
</form.AppForm>
296+
)
297+
}
298+
299+
function ChildComponent() {
300+
const form = useTypedAppFormContext({ ...formOptions })
301+
302+
// You now have access to form components, field components and fields
303+
}
304+
```
305+
251306
## Reusing groups of fields in multiple forms
252307
253308
Sometimes, a pair of fields are so closely related that it makes sense to group and reuse them — like the password example listed in the [linked fields guide](./linked-fields.md). Instead of repeating this logic across multiple forms, you can utilize the `withFieldGroup` higher-order component.

docs/framework/react/reference/functions/createFormHook.md

Lines changed: 70 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ Defined in: [packages/react-form/src/createFormHook.tsx:293](https://github.com/
2929

3030
## Returns
3131

32-
`object`
33-
3432
### useAppForm()
3533

3634
```ts
@@ -97,6 +95,76 @@ useAppForm: <TFormData, TOnMount, TOnChange, TOnChangeAsync, TOnBlur, TOnBlurAsy
9795

9896
`AppFieldExtendedReactFormApi`\<`TFormData`, `TOnMount`, `TOnChange`, `TOnChangeAsync`, `TOnBlur`, `TOnBlurAsync`, `TOnSubmit`, `TOnSubmitAsync`, `TOnDynamic`, `TOnDynamicAsync`, `TOnServer`, `TSubmitMeta`, `TComponents`, `TFormComponents`\>
9997

98+
### useTypedAppFormContext()
99+
100+
```ts
101+
useTypedAppFormContext: <TFormData, TOnMount, TOnChange, TOnChangeAsync, TOnBlur, TOnBlurAsync, TOnSubmit, TOnSubmitAsync, TOnDynamic, TOnDynamicAsync, TOnServer, TSubmitMeta>(_props) => AppFieldExtendedReactFormApi<TFormData, TOnMount, TOnChange, TOnChangeAsync, TOnBlur, TOnBlurAsync, TOnSubmit, TOnSubmitAsync, TOnDynamic, TOnDynamicAsync, TOnServer, TSubmitMeta, TComponents, TFormComponents>;
102+
```
103+
104+
⚠️ **Use withForm whenever possible.**
105+
106+
Gets a typed form from the `<form.AppForm />` context.
107+
108+
#### Type Parameters
109+
110+
##### TFormData
111+
112+
`TFormData`
113+
114+
##### TOnMount
115+
116+
`TOnMount` *extends* `FormValidateOrFn`\<`TFormData`\> \| `undefined`
117+
118+
##### TOnChange
119+
120+
`TOnChange` *extends* `FormValidateOrFn`\<`TFormData`\> \| `undefined`
121+
122+
##### TOnChangeAsync
123+
124+
`TOnChangeAsync` *extends* `FormAsyncValidateOrFn`\<`TFormData`\> \| `undefined`
125+
126+
##### TOnBlur
127+
128+
`TOnBlur` *extends* `FormValidateOrFn`\<`TFormData`\> \| `undefined`
129+
130+
##### TOnBlurAsync
131+
132+
`TOnBlurAsync` *extends* `FormAsyncValidateOrFn`\<`TFormData`\> \| `undefined`
133+
134+
##### TOnSubmit
135+
136+
`TOnSubmit` *extends* `FormValidateOrFn`\<`TFormData`\> \| `undefined`
137+
138+
##### TOnSubmitAsync
139+
140+
`TOnSubmitAsync` *extends* `FormAsyncValidateOrFn`\<`TFormData`\> \| `undefined`
141+
142+
##### TOnDynamic
143+
144+
`TOnDynamic` *extends* `FormValidateOrFn`\<`TFormData`\> \| `undefined`
145+
146+
##### TOnDynamicAsync
147+
148+
`TOnDynamicAsync` *extends* `FormAsyncValidateOrFn`\<`TFormData`\> \| `undefined`
149+
150+
##### TOnServer
151+
152+
`TOnServer` *extends* `FormAsyncValidateOrFn`\<`TFormData`\> \| `undefined`
153+
154+
##### TSubmitMeta
155+
156+
`TSubmitMeta`
157+
158+
#### Parameters
159+
160+
##### \_props
161+
162+
`FormOptions`\<`TFormData`, `TOnMount`, `TOnChange`, `TOnChangeAsync`, `TOnBlur`, `TOnBlurAsync`, `TOnSubmit`, `TOnSubmitAsync`, `TOnDynamic`, `TOnDynamicAsync`, `TOnServer`, `TSubmitMeta`\>
163+
164+
#### Returns
165+
166+
`AppFieldExtendedReactFormApi`\<`TFormData`, `TOnMount`, `TOnChange`, `TOnChangeAsync`, `TOnBlur`, `TOnBlurAsync`, `TOnSubmit`, `TOnSubmitAsync`, `TOnDynamic`, `TOnDynamicAsync`, `TOnServer`, `TSubmitMeta`, `TComponents`, `TFormComponents`\>
167+
100168
### withFieldGroup()
101169

102170
```ts

docs/framework/react/reference/functions/createFormHookContexts.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ title: createFormHookContexts
99
function createFormHookContexts(): object;
1010
```
1111

12-
Defined in: [packages/react-form/src/createFormHook.tsx:68](https://github.com/TanStack/form/blob/main/packages/react-form/src/createFormHook.tsx#L68)
12+
Defined in: [packages/react-form/src/createFormHook.tsx:95](https://github.com/TanStack/form/blob/main/packages/react-form/src/createFormHook.tsx#L95)
1313

1414
## Returns
1515

docs/framework/react/reference/functions/useStore.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ function useStore<TState, TSelected>(
1414
options?): TSelected;
1515
```
1616

17-
Defined in: node\_modules/.pnpm/@tanstack+react-store@0.8.0\_react-dom@19.1.0\_react@19.1.0\_\_react@19.1.0/node\_modules/@tanstack/react-store/dist/esm/index.d.ts:11
17+
Defined in: node\_modules/.pnpm/@tanstack+react-store@0.8.1\_react-dom@19.1.0\_react@19.1.0\_\_react@19.1.0/node\_modules/@tanstack/react-store/dist/esm/index.d.ts:11
1818

1919
### Type Parameters
2020

@@ -53,7 +53,7 @@ function useStore<TState, TSelected>(
5353
options?): TSelected;
5454
```
5555

56-
Defined in: node\_modules/.pnpm/@tanstack+react-store@0.8.0\_react-dom@19.1.0\_react@19.1.0\_\_react@19.1.0/node\_modules/@tanstack/react-store/dist/esm/index.d.ts:12
56+
Defined in: node\_modules/.pnpm/@tanstack+react-store@0.8.1\_react-dom@19.1.0\_react@19.1.0\_\_react@19.1.0/node\_modules/@tanstack/react-store/dist/esm/index.d.ts:12
5757

5858
### Type Parameters
5959

docs/framework/react/reference/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ title: "@tanstack/react-form"
2424
## Variables
2525

2626
- [Field](variables/Field.md)
27+
- [useIsomorphicLayoutEffect](variables/useIsomorphicLayoutEffect.md)
2728

2829
## Functions
2930

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
---
2+
id: useIsomorphicLayoutEffect
3+
title: useIsomorphicLayoutEffect
4+
---
5+
6+
# Variable: useIsomorphicLayoutEffect()
7+
8+
```ts
9+
const useIsomorphicLayoutEffect: (effect, deps?) => void;
10+
```
11+
12+
Defined in: [packages/react-form/src/useIsomorphicLayoutEffect.ts:3](https://github.com/TanStack/form/blob/main/packages/react-form/src/useIsomorphicLayoutEffect.ts#L3)
13+
14+
The signature is identical to `useEffect`, but it fires synchronously after all DOM mutations.
15+
Use this to read layout from the DOM and synchronously re-render. Updates scheduled inside
16+
`useLayoutEffect` will be flushed synchronously, before the browser has a chance to paint.
17+
18+
Prefer the standard `useEffect` when possible to avoid blocking visual updates.
19+
20+
If you’re migrating code from a class component, `useLayoutEffect` fires in the same phase as
21+
`componentDidMount` and `componentDidUpdate`.
22+
23+
## Parameters
24+
25+
### effect
26+
27+
`EffectCallback`
28+
29+
### deps?
30+
31+
`DependencyList`
32+
33+
## Returns
34+
35+
`void`
36+
37+
## Version
38+
39+
16.8.0
40+
41+
## See
42+
43+
[https://react.dev/reference/react/useLayoutEffect](https://react.dev/reference/react/useLayoutEffect)

docs/framework/solid/reference/functions/useStore.md

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,13 @@ title: useStore
88
## Call Signature
99

1010
```ts
11-
function useStore<TState, TSelected>(store, selector?): Accessor<TSelected>;
11+
function useStore<TState, TSelected>(
12+
store,
13+
selector?,
14+
options?): Accessor<TSelected>;
1215
```
1316

14-
Defined in: node\_modules/.pnpm/@tanstack+solid-store@0.7.7\_solid-js@1.9.9/node\_modules/@tanstack/solid-store/dist/esm/index.d.ts:8
17+
Defined in: node\_modules/.pnpm/@tanstack+solid-store@0.8.1\_solid-js@1.9.9/node\_modules/@tanstack/solid-store/dist/esm/index.d.ts:12
1518

1619
### Type Parameters
1720

@@ -33,17 +36,24 @@ Defined in: node\_modules/.pnpm/@tanstack+solid-store@0.7.7\_solid-js@1.9.9/node
3336

3437
(`state`) => `TSelected`
3538

39+
#### options?
40+
41+
`UseStoreOptions`\<`TSelected`\>
42+
3643
### Returns
3744

3845
`Accessor`\<`TSelected`\>
3946

4047
## Call Signature
4148

4249
```ts
43-
function useStore<TState, TSelected>(store, selector?): Accessor<TSelected>;
50+
function useStore<TState, TSelected>(
51+
store,
52+
selector?,
53+
options?): Accessor<TSelected>;
4454
```
4555

46-
Defined in: node\_modules/.pnpm/@tanstack+solid-store@0.7.7\_solid-js@1.9.9/node\_modules/@tanstack/solid-store/dist/esm/index.d.ts:9
56+
Defined in: node\_modules/.pnpm/@tanstack+solid-store@0.8.1\_solid-js@1.9.9/node\_modules/@tanstack/solid-store/dist/esm/index.d.ts:13
4757

4858
### Type Parameters
4959

@@ -65,6 +75,10 @@ Defined in: node\_modules/.pnpm/@tanstack+solid-store@0.7.7\_solid-js@1.9.9/node
6575

6676
(`state`) => `TSelected`
6777

78+
#### options?
79+
80+
`UseStoreOptions`\<`TSelected`\>
81+
6882
### Returns
6983

7084
`Accessor`\<`TSelected`\>

0 commit comments

Comments
 (0)