Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

135
Vistas
RTK query is looping over result but not providing the expected content

I'm currently doing the Redux Essentials tutorial and stuck in chapter 7: When switching from the classical thunk to the RTK query, the mapping will not work:

content = posts.map(post => <PostExcerpt key={post.id} post={post} />)

The error message is:

Unhandled Rejection (TypeError): Cannot read properties of undefined (reading 'title')

To find the reason, I've broken the code down to something simple as follows:

} else if (isSuccess) {
    content = '';
    //content = posts.map(post => <PostExcerpt key={post.id} postId={post}/>);
    if (posts !== undefined) {
        for (const post1 in posts)
            if (post1 !== undefined) content +=
                ' loop: ' + post1.toString() + ' typ: ' + typeof(post1) + ' ID: ' + post1.title + '!!';
            else content += 'kein post';
    }

The output of my curious code is:

loop: 0 typ: string ID: undefined!! loop: 1 typ: string ID: undefined!! loop: 2 typ: string ID: undefined!!

So it is looping but not having the right values in the variable. This is weird as the posts variable seems to have the right content. Here is the output of the evaluation:

Evaluation of "posts" variable

Opening the Sandbox at the end of the mentioned tutorial page also does not render the posts - so there might be a bug somewhere.

As I didn't find any similar problem description, I hope, you may give me a hint of what is wrong.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

It is running now without problem. To be honest, I unfortunately do not know, why. Can't find any difference in my code history, which might allow to recognize, what happend. Bizarre...

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda