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 the way you think, not the way your CMS thinks

Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.

Was this answer helpful?