Skip to content

Multi-tenant example: Cannot destructure property 'config' of '(0 , _chunk_PKQOCWZD_js__WEBPACK_IMPORTED_MODULE_11__.b)(...)' #11687

Description

@gjsoaresc

Describe the Bug

I'm running a multi-tenant Payload v3 app based on the official example.

`
⨯ TypeError: Cannot destructure property 'config' of '(0 , chunk_PKQOCWZD_js__WEBPACK_IMPORTED_MODULE_11_.b)(...)' as it is undefined.
at TenantField (......\src\components\TenantField\index.client.tsx:20:56)
18 | export const TenantField = (args: Props) => {
19 | const { debug, path, unique } = args

20 | const { setValue, value } = useField<number | string>({ path })
| ^
21 | const { options, selectedTenantID, setPreventRefreshOnChange, setTenant } = useTenantSelection()
22 |
23 | const hasSetValueRef = React.useRef(false) {
digest: '3372345123'
}
`

Based on my analysis, I can see that the error is occurring in the TenantField component when trying to use the useField hook. The error message indicates that it's trying to destructure the config property from something that is undefined.
The issue appears to be related to the version compatibility between the multi-tenant plugin and the UI package. Both are at version 3.28.1, but there might be an issue with how the useField hook is being imported or used.

It works well using 3.27.0 version.

Link to the code that reproduces this issue

https://github.com/payloadcms/payload/tree/main/examples/multi-tenant

Reproduction Steps

  1. npx create-payload-app --example multi-tenant
  2. update payload and its dependencies to v3.28.1
  3. open browser and try to create a record inside any collection that is not global and is managed by tenant

Which area(s) are affected? (Select all that apply)

plugin: other

Environment Info

Node: 22.12.0
payload: 3.28.1
next: 15.2.2
@payloadcms/db-sqlite: 3.28.1
@payloadcms/plugin-multi-tenant: 3.28.1
@payloadcms/ui: 3.28.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions