From e40c82161ebf71ae18842096164606e9829b61f0 Mon Sep 17 00:00:00 2001 From: Alessio Gravili Date: Wed, 10 Sep 2025 10:33:32 -0700 Subject: [PATCH] fix(next): error after logging in and navigating to different page in production (#13758) Since https://github.com/payloadcms/payload/pull/13714, if you open payload, log in, then client-side navigate to any page (e.g. clicking on any collection), the following error will appear and crash the page: Screenshot 2025-09-09 at 18 35
46@2x This only happens in production. It does not happen during development, because the `SyncClientConfig` `useEffect` runs twice due to react strict mode. --- - To see the specific tasks where the Asana app for GitHub is being used, see below: - https://app.asana.com/0/0/1211306293437542 --- packages/next/src/views/Root/SyncClientConfig.tsx | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/packages/next/src/views/Root/SyncClientConfig.tsx b/packages/next/src/views/Root/SyncClientConfig.tsx index 85cf35a89..46579be35 100644 --- a/packages/next/src/views/Root/SyncClientConfig.tsx +++ b/packages/next/src/views/Root/SyncClientConfig.tsx @@ -2,7 +2,7 @@ import type { ClientConfig } from 'payload' import { useConfig } from '@payloadcms/ui' -import { useEffect, useRef } from 'react' +import { useEffect } from 'react' /** * This component is required in order for the _page_ to be able to refresh the client config, @@ -12,15 +12,8 @@ import { useEffect, useRef } from 'react' */ export const SyncClientConfig = ({ clientConfig }: { clientConfig: ClientConfig }) => { const { setConfig } = useConfig() - const initialRender = useRef(true) useEffect(() => { - // Can skip the initial render, as the config will already be set by the layout - if (initialRender.current) { - initialRender.current = false - return - } - setConfig(clientConfig) }, [clientConfig, setConfig])