diff --git a/packages/sanity/playwright-ct/tests/formBuilder/utils/TestForm.tsx b/packages/sanity/playwright-ct/tests/formBuilder/utils/TestForm.tsx index 96b71978868..2603d5d2176 100644 --- a/packages/sanity/playwright-ct/tests/formBuilder/utils/TestForm.tsx +++ b/packages/sanity/playwright-ct/tests/formBuilder/utils/TestForm.tsx @@ -186,7 +186,9 @@ export function TestForm(props: TestFormProps) { }, [setFocusPath]) const patchRef = useRef<(event: PatchEvent) => void>(() => { - throw new Error('Nope') + throw new Error( + 'Attempted to patch the Sanity document during initial render. Input components should only call `onChange()` in an effect or a callback.', + ) }) patchRef.current = (event: PatchEvent) => { diff --git a/packages/sanity/src/core/tasks/components/form/tasksFormBuilder/useTasksFormBuilder.ts b/packages/sanity/src/core/tasks/components/form/tasksFormBuilder/useTasksFormBuilder.ts index 9a5d1cc6ae9..37001003c45 100644 --- a/packages/sanity/src/core/tasks/components/form/tasksFormBuilder/useTasksFormBuilder.ts +++ b/packages/sanity/src/core/tasks/components/form/tasksFormBuilder/useTasksFormBuilder.ts @@ -81,7 +81,9 @@ export function useTasksFormBuilder(options: TasksFormBuilderOptions): TasksForm const {patch} = useDocumentOperation(documentId, documentType) const patchRef = useRef<(event: PatchEvent) => void>(() => { - throw new Error('Nope') + throw new Error( + 'Attempted to patch the Sanity document during initial render. Input components should only call `onChange()` in an effect or a callback.', + ) }) useEffect(() => { patchRef.current = (event: PatchEvent) => { diff --git a/packages/sanity/src/structure/panes/document/DocumentPaneProvider.tsx b/packages/sanity/src/structure/panes/document/DocumentPaneProvider.tsx index 8f85d2d74d4..d35ec275dad 100644 --- a/packages/sanity/src/structure/panes/document/DocumentPaneProvider.tsx +++ b/packages/sanity/src/structure/panes/document/DocumentPaneProvider.tsx @@ -296,7 +296,9 @@ export const DocumentPaneProvider = memo((props: DocumentPaneProviderProps) => { ) const patchRef = useRef<(event: PatchEvent) => void>(() => { - throw new Error('Nope') + throw new Error( + 'Attempted to patch the Sanity document during initial render. Input components should only call `onChange()` in an effect or a callback.', + ) }) useEffect(() => { patchRef.current = (event: PatchEvent) => {