Structured Content 2022: Join our conference to explore fresh perspectives on content and digital experiences →

Hej, I am creating slideshow module in sanity, but I get this error: ```An error occured: Invalid item type: "[object Object]". Default array input can only contain objects...

1 replies
Last updated: Jan 6, 2021

Hej, I am creating slideshow module in sanity, but I get this error:

An error occured: Invalid item type: "[object Object]". Default array input can only contain objects (for now)
Check your browser's JavaScript console for details.
Here is my fields

export default {
  title: 'Slideshow Module',
  name: 'slideshowModule',
  type: 'array',
  hidden: true,
  of: [
    {
      type: 'object',
      fields: [
        {
          name: 'headline',
          title: 'Headline',
          type: 'localeString'
        },
        {
          name: 'subtitle',
          title: 'Subtitle',
          type: 'localeString'
        },
        {
          name: 'images',
          title: 'Images',
          type: 'imageModule'
        }
      ]
    }
  ]
}

Jan 6, 2021, 10:39 AM

This is because

slideshowModule
 is an
array
 and you use it in a rich text field which is also an array. The way to solve it is to make the
slideshowModule
 an
object
 with one
array
 type for the images.
I'd check out this guide:
https://www.sanity.io/blog/creating-custom-content-blocks-gutenberg-vs-sanity

Jan 6, 2021, 1:05 PM

Sanity.io: Get the most out of your content

Sanity.io is a platform to build websites and applications. It comes with great APIs that let you treat content like data. Give your team exactly what they need to edit and publish their content with the customizable Sanity Studio. Get real-time collaboration out of the box. Sanity.io comes with a hosted datastore for JSON documents, query languages like GROQ and GraphQL, CDNs, on-demand asset transformations, presentation agnostic rich text, plugins, and much more.

Don't compromise on developer experience. Join thousands of developers and trusted companies and power your content with Sanity.io. Free to get started, pay-as-you-go on all plans.