Sanity Library Reference Docs
    Preparing search index...

    Function isIncomingReferenceCreation

    • Beta

      Helper function to check if the document is being created from an incoming reference. It will be used in the initialValue callback to determine if the document is being created from an incoming reference.

      example:

      defineType({
      name: 'book',
      type: 'document',
      fields: [...],
      initialValue: (params) => {
      // If the document is being created from an incoming reference, return the reference
      // Otherwise, return undefined
      return {
      author: isIncomingReferenceCreation(params) ? params.reference : undefined,
      }
      },
      })

      Parameters

      Returns initialValue is IncomingReferenceCreationParams