👀 See Sanity in action: Watch product demo now →

I just encountered this error when trying to create an array with two types. Is this not possible, or am I doing something wrong? 😬

1 replies
Last updated: Jan 27, 2021
I just encountered this error when trying to create an array with two types. Is this not possible, or am I doing something wrong? 😬
Jan 27, 2021, 8:34 PM
It's a bit subtle, but
image
 is an actually an object type, and you can't mix primitive types (like numbers and strings) with object types. That means that you have to put your
string
 inside of an object. So:
of: [ { type: 'object', fields: [{type: 'string', name: 'text'}]}, { type: 'image' }]

Jan 27, 2021, 8:36 PM

Sanity.io – build remarkable experiences at scale

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

Categorized in