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

420
Visualizações
when I try to destructing the data from react query I am getting Property 'data' does not exist on type 'void'

I am facing issue with react query when I try to destructing the data like this way const {data: getAllChannelSettingTypes} = useGetAllChannelSettingTypes(); I am gettin this error Property 'data' does not exist on type 'void'

Maybe there is a problem with returning the userQueries

const useGetAllChannelSettingTypes = () => {
  const {data: defaultSettingTypes} = useQuery(SETTING_TYPES, () =>
    Api.user.getSettingTypes(),
  );
  const userQueries = useQueries(
    defaultSettingTypes.map((type: any) => {
      return {
        queryKey: ['SETTING_VALUE', type.channelSettingTypeId],
        queryFn: () => Api.user.getSettingValues(type.channelSettingTypeId),
      };
    }),
  );
  console.log(userQueries);
  return userQueries;
};
about 4 years ago · Santiago Gelvez
2 Respostas
Responde à pergunta

0

According to the documentation useQueries returns an array:

The useQueries hook returns an array with all the query results.

Each element in the array has these properties:

  • status: String
  • isIdle: boolean
  • isLoading: boolean
  • isSuccess: boolean
  • isError: boolean
  • isLoadingError: boolean
  • isRefetchError: boolean
  • data: TData, defaults to undefined.
  • dataUpdatedAt: number
  • error: null | TError
  • errorUpdatedAt: number
  • isStale: boolean
  • isPlaceholderData: boolean
  • isPreviousData: boolean
  • isFetched: boolean
  • isFetchedAfterMount: boolean
  • isFetching: boolean
  • isRefetching: boolean
  • failureCount: number
  • errorUpdateCount: number
  • refetch: (options: { throwOnError: boolean, cancelRefetch: boolean }) => Promise
  • remove: () => void

So try destructing the data in a loop like this:

for(let i = 0; i < userQueries.length; i++){
  const {data: getAllChannelSettingTypes} = useGetAllChannelSettingTypes()
  // do something with that data of the given query
}

If you are only interested in the first result you could do it like this:

const {data: getAllChannelSettingTypes} = useGetAllChannelSettingTypes()[0]
   

about 4 years ago · Santiago Gelvez Relatório

0

try removing the params "data"

about 4 years ago · Santiago Gelvez 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