Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions packages/react-form/src/ReactForm/fieldSubscriptions.lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@ import type { AnyInternalFieldApi } from '@tanstack/form-core/internals'
export function useValueFieldSubscription(
fieldApi: AnyInternalFieldApi,
): AnyInternalFieldApi {
const value = useSelector(fieldApi.atom, (state) => state.value)
const meta = useSelector(fieldApi.atom, (state) => state.meta)
const state = useSelector(fieldApi.atom)

return useMemo(() => {
void meta
void value
void state
return Object.create(fieldApi)
}, [fieldApi, meta, value])
}, [fieldApi, state])
}

export function useArrayFieldSubscription(
Expand Down
4 changes: 2 additions & 2 deletions packages/react-form/tests/FormGroup.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ describe('FormGroup', () => {
expect(getByTestId('app-field-name')).toHaveTextContent('guestDetails.name')
})

it('uses the AppForm field provider subscription for field context', async () => {
it('uses one AppForm field provider subscription for field context', async () => {
const subscribe = vi.fn()
const unsubscribe = vi.fn()
const instrumentedAtoms = new WeakSet<object>()
Expand Down Expand Up @@ -169,7 +169,7 @@ describe('FormGroup', () => {

await vi.waitFor(() => {
expect(subscribe.mock.calls.length - unsubscribe.mock.calls.length).toBe(
2,
1,
)
})

Expand Down