You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a Reviews block, which references a collection of Reviews as a relationship (hasMany).
In a collection called Pages I reference the block under a tab Content, but I get the following error when trying to add a Review:
Error: Objects are not valid as a React child (found: object with keys {firstName, lastName, description}). If you meant to render a collection of children, use an array instead.
I believe this is to do with a group/block nested problem, but I can't be sure.
Reviews Collection
importtype{CollectionConfig}from'payload';exportconstReviews: CollectionConfig={slug: 'reviews',labels: {singular: 'Testimonial',plural: 'Testimonials',},admin: {useAsTitle: 'author',},typescript: {interface: 'Review',},fields: [{name: 'content',label: 'Content',type: 'textarea',required: true,admin: {description: 'The content of the review or testimonial.',},},{name: 'author',type: 'group',admin: {hideGutter: true,},fields: [{type: 'row',fields: [{name: 'firstName',label: 'First Name',type: 'text',required: true,admin: {width: '50%',description: 'The first name of the author.',},},{name: 'lastName',label: 'Last Name',type: 'text',required: true,admin: {width: '50%',description: 'The last name of the author.',},},{name: 'description',label: 'Description',type: 'text',required: true,admin: {description:
'Give a brief description of the author, such as their role or position.',},},],},],},],};
Reviews Block
importtype{Block}from'payload';exportconstReviews: Block={slug: 'reviews-block',interfaceName: 'BlockReviews',labels: {singular: 'Testimonial',plural: 'Testimonials',},fields: [{name: 'title',type: 'text',label: 'Title',required: true,admin: {description: 'Add a title for the testimonial block.',},},{name: 'content',type: 'textarea',label: 'Content',admin: {description: 'Add a content for the testimonial block.',},},{type: 'relationship',name: 'items',label: 'Reviews',relationTo: 'reviews',hasMany: true,admin: {isSortable: true,},},],};
Pages Collection:
import{Reviews}from'@/blocks/Reviews';importtype{CollectionConfig}from'payload';exportconstPages: CollectionConfig={slug: 'pages',timestamps: true,labels: {singular: 'Page',plural: 'Pages',},versions: {drafts: true,maxPerDoc: 5,},fields: [{type: 'tabs',tabs: [{label: 'Hero',fields: [{name: 'hero',type: 'group',label: 'Hero',admin: {hideGutter: true,},fields: [{name: 'title',label: 'Title',type: 'text',required: true,admin: {description: 'The main title of the page.',},},{name: 'lead',label: 'Lead',type: 'textarea',required: true,admin: {description:
'A short description that appears below the title.',},},],},],},{label: 'Content',fields: [{name: 'layout',type: 'blocks',required: true,blocks: [Reviews,],},],},],},],};
Describe the Bug
I have a
Reviews
block, which references a collection ofReviews
as a relationship (hasMany).In a collection called
Pages
I reference the block under a tabContent
, but I get the following error when trying to add a Review:I believe this is to do with a group/block nested problem, but I can't be sure.
Reviews Collection
Reviews Block
Pages Collection:
Link to the code that reproduces this issue
https://github.com/ainsleydev/payload-issue
Reproduction Steps
testimonial
block in pages.Which area(s) are affected? (Select all that apply)
area: core
Environment Info
The text was updated successfully, but these errors were encountered: