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

424
Vistas
How to solve this: TypeError: Cannot destructure property 'title' of 'collections' as it is undefined

This is the data that I fetched from firestore and I want to use it in my application to show the product details but I can't retrieve it into my application. Example, I want the data from shop->collections->bags->items to show the specific product details.

data fetched

And here is my code in product-details.component.jsx:

import React, { useEffect, useState } from "react";
import { connect } from "react-redux";

import { fetchCollectionsStart } from '../../redux/shop/shop.actions'


const ProductDetailsPage = ({ fetchCollectionsStart, match, collections }) => {

    const {title, items} = collections;

    useEffect(() => {
        fetchCollectionsStart();
    }, [fetchCollectionsStart]);

    console.log(match);

    const ShowProduct = () => {
        return (
            <div>
                {title}
            </div>
        )
    }

    return (
        <div className='product-details'>
            <div className="row">
                <ShowProduct />
            </div>
        </div>
    );

};

const mapDispatchToProps = dispatch => ({
    fetchCollectionsStart: () => dispatch(fetchCollectionsStart())
});

export default connect(null, mapDispatchToProps)(ProductDetailsPage);

The error pop up is shown as the image below: Error

I don't know why I can't destructure the data from collections. I thought I already successfully fetched it into my application? Thanks a lot for helping me!!

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

0

You need to destructure bags and then get the title from bags.

const { bags } = collections;
console.log(bags.title)

If you dont know whats in collections - you can use Object.keys() to get the different object keys- bags, boys, girls, hats etc.

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