Go Behind the Experience to see how Tecovas brings the West to life with Sanity 🤠 July 18th

Building custom input component with expanding list causing issues

1 replies
Last updated: Jun 1, 2023
I'm building a custom input component for a string where I use
props.renderDefault
and I expand the list in the options, since I expand the list by using:
props.schemaType.options = {...props.schemaType.options, list: [...list, ...myList]}
the list in the field keeps getting bigger, looks like that in each render the list I get is the list after it was already expanded (no the original list from 'options')
How can I fix that?
Jun 1, 2023, 2:41 PM
Well, I guess this solves it and I shouldn't assign to options directly
 return props.renderDefault({
    ...props,
    schemaType: {
      ...props.schemaType,
      options: {...props.schemaType.options, list: [...list, ...myList]},
    },
  })
Jun 1, 2023, 2:45 PM

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?