|
1 | 1 | import type { AdminViewComponent, AdminViewProps, EditViewComponent } from 'payload'
|
2 | 2 |
|
3 | 3 | import { DocumentInfoProvider, EditDepthProvider, HydrateClientUser } from '@payloadcms/ui'
|
4 |
| -import { RenderCustomComponent, formatAdminURL , isEditing as getIsEditing } from '@payloadcms/ui/shared' |
| 4 | +import { |
| 5 | + RenderCustomComponent, |
| 6 | + formatAdminURL, |
| 7 | + isEditing as getIsEditing, |
| 8 | +} from '@payloadcms/ui/shared' |
5 | 9 | import { notFound, redirect } from 'next/navigation.js'
|
| 10 | +import { deepCopyObjectSimple } from 'payload' |
6 | 11 | import React from 'react'
|
7 | 12 |
|
8 | 13 | import type { GenerateEditViewMetadata } from './getMetaBySegment.js'
|
@@ -208,7 +213,15 @@ export const Document: React.FC<AdminViewProps> = async ({
|
208 | 213 | permissions={permissions}
|
209 | 214 | />
|
210 | 215 | )}
|
211 |
| - <HydrateClientUser permissions={permissions} user={user} /> |
| 216 | + {/** |
| 217 | + * After bumping the Next.js canary to 104, and React to 19.0.0-rc-06d0b89e-20240801" we have to deepCopy the permissions object (https://github.com/payloadcms/payload/pull/7541). |
| 218 | + * If both HydrateClientUser and RenderCustomComponent receive the same permissions object (same object reference), we get a |
| 219 | + * "TypeError: Cannot read properties of undefined (reading '$$typeof')" error when loading up some version views - for example a versions |
| 220 | + * view in the draft-posts collection of the versions test suite. RenderCustomComponent is what renders the versions view. |
| 221 | + * |
| 222 | + * // TODO: Revisit this in the future and figure out why this is happening. Might be a React/Next.js bug. We don't know why it happens, and a future React/Next version might unbreak this (keep an eye on this and remove deepCopyObjectSimple if that's the case) |
| 223 | + */} |
| 224 | + <HydrateClientUser permissions={deepCopyObjectSimple(permissions)} user={user} /> |
212 | 225 | <EditDepthProvider
|
213 | 226 | depth={1}
|
214 | 227 | key={`${collectionSlug || globalSlug}${locale?.code ? `-${locale?.code}` : ''}`}
|
|
0 commit comments