Unlock seamless workflows and faster delivery with our latest releases - Join the deep dive

Clarification on the correct usage of `defineField` and `defineArrayMember` in a Slack thread.

7 replies
Last updated: Aug 29, 2023
defineField({
      title: "Navigation",
      description: "Select pages or link for main navigation",
      name: "navigation",
      type: "array",
      group: "navigation",
      of: [
        defineField({
          title: "Internal Link",
          name: "internalLink",
          type: "internalLink"
        }),
        defineField({
          title: "External Link",
          name: "externalLink",
          type: "externalLink"
        })
      ]
    }),
Quick question, isn't this supposed to be defineArrayMember instead of defineField on the type errors?
Aug 29, 2023, 8:13 AM
I believe
defineArrayMember
is the right one đź‘Ť
Aug 29, 2023, 8:22 AM
Thank you
Aug 29, 2023, 8:39 AM
So to confirm anything inside OF or TO is an arrayMembrer?
Aug 29, 2023, 8:39 AM
if the parent type is array the of or to is an arrayMember correct?
Aug 29, 2023, 8:40 AM
you know what, I don’t think the
to
array is typed at all . It only supports simple
{type: 'documentTypeName'}
objects, so my guess is that we didn’t see it as super useful
Aug 29, 2023, 8:56 AM
so
defineArrayMember
is only for objects in the
of
array
Aug 29, 2023, 8:56 AM
Great thank you very much!
Aug 29, 2023, 8:56 AM

Sanity– build remarkable experiences at scale

Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?