Files
payload/test/form-state/collections/Posts/RenderTracker.tsx
Jacob Fletcher b81358ce7e fix(ui): form state infinite render (#11665)
The task queue triggers an infinite render of form state. This is
because we return an object from the `useQueues` hook that is recreated
on every render. We then use the `queueTask` function as an unstable
dependency of the `useEffect` responsible for requesting new form state,
ultimately triggering an infinite rendering loop.

The fix is to stabilize the `queueTask` function within a `useCallback`.
Adds a test to prevent future regression.
2025-03-12 15:06:06 -04:00

11 lines
282 B
TypeScript

'use client'
import type { TextFieldClientComponent } from 'payload'
import { useField } from '@payloadcms/ui'
export const RenderTracker: TextFieldClientComponent = ({ path }) => {
useField({ path })
console.count('Renders') // eslint-disable-line no-console
return null
}