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.
11 lines
282 B
TypeScript
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
|
|
}
|