Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

144
Visualizações
schemaTypes in sanity io

I am facing problem in schemaTypes of Sanity io All the details are mentioned below Any problem regarding the question U can ask me

userSchema.js

    name:'abouts',
    title:'Abouts',
    type: 'document',
    fields:[
        {
            name:'title',
            title:'Title',
            type:'string'
        },
        {
            name:'description',
            title:'Description',
            type:'string'
        },
        {
            name:'imgUrl',
            title:'ImgUrl',
            type: 'image',
            options: {
              hotspot: true,
            },
        },

    ]
} 

schema.js

import createSchema from 'part:@sanity/base/schema-creator'
import schemaTypes from 'all:part:@sanity/base/schema-type'
import { userSchema } from './userSchema'

export default createSchema({
  
  name: 'default',
  types: schemaTypes.concat([userSchema]),
}) 

Now, schemaTypes is an OBJECT as we can check from "typeof" operator, I dont understand how can we use .concat() with an Object, like .concat() is an array function which can be applied with Array, So how schemaTypes.concat([userSchema]) is working correctly??

Please help me regarding this. Thanks

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

In JavaScript you will never get 'array' back from typeof. typeof will return 'object' for any non-primitive other than functions (and the primitive null).

What I expect you are looking for is the Array.isArray() method. Logging Array.isArray(schemaTypes) should return true, meaning that schemaTypes is in fact an array and can use the .concat() method.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda