Closed jomapps closed 4 days ago
I believe what you're looking for is "Custom Component import changes" from the v3.0.0-beta.79 changelog.
The way to import components has changed from importing it directly to providing a path to the component.
https://github.com/payloadcms/payload/releases/tag/v3.0.0-beta.79
This is exactly right ^
@jomapps please have a look at this example also in our website template https://github.com/payloadcms/payload/blob/beta/templates/website/src/fields/slug/index.ts
That solved it. PERFECT. Thank you so much.
This issue has been automatically locked. Please open a new issue if this issue persists with any additional detail.
Link to reproduction
No response
Environment Info
Describe the Bug
when I do localhost:3000/admin
✓ Compiled /admin/[[...segments]] in 10.1s (5813 modules) ⨯ Internal error: Error: Cannot access default.path on the server. You cannot dot into a client module from a server component. You can only pass the imported name through. at Object.get (C:\Projects\payload-3.0-demo\node_modules.pnpm\next@15.0.0-canary.160_babel-plugin-react-compiler@0.0.0-experimental-48eb8f4-20240822_react-_h5xpl647asxd57i2pwzfqhepry\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:114:73177) at parsePayloadComponent (./node_modules/.pnpm/payload@3.0.0-beta.108_graphql@16.9.0_monaco-editor@0.38.0_react-dom@19.0.0-rc-5dcb0097-20240_qotjvbfsl2c632rzjl4krqrh4a/node_modules/payload/dist/bin/generateImportMap/parsePayloadComponent.js:9:107) at getComponent (./node_modules/.pnpm/@payloadcms+ui@3.0.0-beta.108_monaco-editor@0.38.0_next@15.0.0-canary.160_babel-plugin-react-_4eoe4mrp7rygkp4yr3jmboandq/node_modules/@payloadcms/ui/dist/providers/Config/createClientConfig/getComponent.js:27:76) at createSingleMappedComponent (./node_modules/.pnpm/@payloadcms+ui@3.0.0-beta.108_monaco-editor@0.38.0_next@15.0.0-canary.160_babel-plugin-react-_4eoe4mrp7rygkp4yr3jmboandq/node_modules/@payloadcms/ui/dist/providers/Config/createClientConfig/getCreateMappedComponent.js:55:71) at createMappedComponent (./node_modules/.pnpm/@payloadcms+ui@3.0.0-beta.108_monaco-editor@0.38.0_next@15.0.0-canary.160_babel-plugin-react-_4eoe4mrp7rygkp4yr3jmboandq/node_modules/@payloadcms/ui/dist/providers/Config/createClientConfig/getCreateMappedComponent.js:104:14) at createClientField (./node_modules/.pnpm/@payloadcms+ui@3.0.0-beta.108_monaco-editor@0.38.0_next@15.0.0-canary.160_babel-plugin-react-_4eoe4mrp7rygkp4yr3jmboandq/node_modules/@payloadcms/ui/dist/providers/Config/createClientConfig/fields.js:278:42) at createClientFields (./node_modules/.pnpm/@payloadcms+ui@3.0.0-beta.108_monaco-editor@0.38.0_next@15.0.0-canary.160_babel-plugin-react-_4eoe4mrp7rygkp4yr3jmboandq/node_modules/@payloadcms/ui/dist/providers/Config/createClientConfig/fields.js:307:22) at createClientCollectionConfig (./node_modules/.pnpm/@payloadcms+ui@3.0.0-beta.108_monaco-editor@0.38.0_next@15.0.0-canary.160_babel-plugin-react-_4eoe4mrp7rygkp4yr3jmboandq/node_modules/@payloadcms/ui/dist/providers/Config/createClientConfig/collections.js:23:91) at createClientCollectionConfigs (./node_modules/.pnpm/@payloadcms+ui@3.0.0-beta.108_monaco-editor@0.38.0_next@15.0.0-canary.160_babel-plugin-react-_4eoe4mrp7rygkp4yr3jmboandq/node_modules/@payloadcms/ui/dist/providers/Config/createClientConfig/collections.js:197:28) at createClientConfig (./node_modules/.pnpm/@payloadcms+ui@3.0.0-beta.108_monaco-editor@0.38.0_next@15.0.0-canary.160_babel-plugin-react-_4eoe4mrp7rygkp4yr3jmboandq/node_modules/@payloadcms/ui/dist/providers/Config/createClientConfig/index.js:92:108) at RootLayout (./node_modules/.pnpm/@payloadcms+next@3.0.0-beta.108_graphql@16.9.0_monaco-editor@0.38.0_next@15.0.0-canary.160_ba_cqzhh2zxpwa354mueqkhu3ps7m/node_modules/@payloadcms/next/dist/layouts/Root/index.js:116:140) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) digest: "2607949399"
Reproduction Steps
This is a field component i was using fine in a collection till beta.67. After the upgrade to beta.108 it does not work with the error above. Has something changed? I was not able to find anything in the breaking changes.
If I remove this, code works fine.
in my collection I have:
fields: [ TitleInputPlaceField, ...
My component is: ` 'use client' import * as React from 'react' import { useField, useLocale, useDocumentInfo } from '@payloadcms/ui' import getGoogleMatch from '@/travelm/utilities/getGoogleMatch'const CustomTextPlaceMatchComponent: React.FC<{ path: string }> = ({ path }) => { const { value, setValue } = useField({ path })
const [lastValue, setLastValue] = React.useState('')
const [options, setOptions] = React.useState<string[]>([])
const derivedLocale = useLocale()
let locale = 'de'
if (derivedLocale?.code) locale = derivedLocale.code
const docInfo = useDocumentInfo()
React.useEffect(() => { const fetchOptions = async (value: string, locale: string) => { const data = await getGoogleMatch(value, locale) setOptions( data.map((item: any) =>
${item.placeId} :: ${item.name} :: ${item.formattedAddress}
), ) } if (value !== lastValue && !docInfo?.initialData?.placeId) { fetchOptions(value, locale.toString()) setLastValue(value) } }, [value, lastValue, locale, docInfo])return ( <>
) }
export default CustomTextPlaceMatchComponent
And I define the field as :
import { Field } from 'payload' import CustomTextPlaceMatchComponent from '@/travelm/fields/TitleInputPlaceField/component'const TitleInputPlaceField: Field = { name: 'title', type: 'text', label: { en: 'Title', de: 'Titel', }, localized: true, index: true, required: true, admin: { components: { Field: CustomTextPlaceMatchComponent, }, }, }
export default TitleInputPlaceField
`
Adapters and Plugins
No response