The function myComponent.map does not exist

I am currently storing information that I am trying to pass to a component responsible for creating Tabs and TabPanel components (Material-UI) based on the provided data.

Here is how the information is structured:

let eventCard = [
    {
        title: "The Summit",
        learnMore: true,
        description: "5 days of inspiring conversations with explorers, influencers, and experts discussing the future of tourism.",
        eventCalendar: [
            {
                date: "May 3, 2021",
                location: "11am to 1pm, Québec (UTC-4)"
            }
        ]
    },
    {
        title: "The Summit",
        learnMore: true,
        description: "5 days of inspiring conversations with explorers, influencers, and experts discussing the future of tourism.",
        eventCalendar: [
            {
                date: "May 3, 2021",
                location: "11am to 1pm, Québec (UTC-4)"
            }
        ]
    }
]

Next, I pass this information to my component like so:

<EventCard eventCard={eventCard}/>

On the other end, I have an interface containing the same details:

interface IEventCard {
    title?: string;
    learnMore?: boolean;
    description: string;
    eventCalendar?: IEventCalendar[];
}

This information is received in the function EventCard:

export default function EventCard(eventCard : IEventCard[]) {

    const [value, setValue] = useState(1);

    const handleChange = (event: any, newValue: React.SetStateAction<number>) => {
        setValue(newValue);
    };

    return (
        <Grid className='EventCard-Background' container spacing={3}>
            <Tabs value={value} onChange={handleChange}>
                {eventCard && GenerateTabs(eventCard)}
            </Tabs>
            {GenerateTabPanels(eventCard, value.toString())}
        </Grid>
    );
}

When viewing the object in the console, it appears as follows: eventCard: eventCard Array(2)

The issue arises when attempting to use eventCard.map, resulting in an error stating that eventCard.map is not a function. Even running Array.Array(eventCard) indicates that eventCard is not an array. I am uncertain how to resolve this problem.

Apologies if this question seems disorganized; it is my first post here. Any guidance on improving clarity in my future questions would be appreciated.

Answer №1

To properly utilize props, you must either receive and use props.EventCard within the component or destructure it using {eventCard}

export default function EventCard(props)

or

export default function EventCard({eventCard : IEventCard[]})

gl

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Traverse a deeply nested JSON structure

I need assistance with looping through a complex JSON object using only JavaScript. My goal is to log each item along with its properties into the console. const nested_json = { "item1":{ "name": "banana", ...

Steps for successfully sending data to a MenuItem event handlerExplanation on how to

My issue arises when I attempt to render a Menu for each element in an array, as the click handlers for the items only receive the final element in the array rather than the specific element used for that particular render. The scenario involves having a ...

Strategies for transferring data between controllers and configuration files in AngularJS

I'm attempting to pass a variable to the angular js config, Here is my JavaScript app: var app = angular.module('myApp', ['ngMaterial', 'sasrio.angular-material-sidenav', 'ui.router']); app.controller('ba ...

Creating a personalized Autocomplete feature using React Material-UI with the help of the renderInput method

I'm currently using a React Material UI Autocomplete component, similar to the one in the official documentation. For example, let's consider a list of countries: import * as React from 'react'; import Box from '@mui/material/Box& ...

Preventing Browser Back Button Functionality in Angular 2

I'm currently working on an Angular 2 website and wondering if there is a way to either disable or trigger the browser's back button using Angular 2. Any insights would be greatly appreciated! ...

Instructions on converting XML data obtained from an AJAX call into a downloadable file

I've been struggling with converting an AJAX response containing XML text into a downloadable file. I've tried various methods but haven't had success. In the past, I was able to work with a similar scenario involving a pdf, where the conte ...

Troubleshoot Nested Array URL Parameter Problems in Node.js

I am encountering an issue with extracting data from an array that I am sending to my API through an AXIOS call to Express. The call is sent successfully, but the issue arises when trying to access the data in the property_features parameter. Even though m ...

Modifying the image height in a column using Bootstrap and JSON data

My webpage is dynamically generating images from a JSON file through a JavaScript file. However, the images are displaying at different heights, and I want each column to adjust to the height of the image to eliminate any gaps. Particularly, data with the ...

Issue connecting to Oracle database: Unable to access properties of undefined (attempting to read '_getConnection')

Encountering an issue with node oracle connection. It was successfully connected before in the same application, but now it is not working after updating the node version. The connection string seems fine as the same connection is working in another appli ...

Remove the user along with all of their associated documents from Firestore

When a user wants to delete their account, I need to ensure that the 'documents' they created in Firebase are deleted as well. After some research online, I came across the following code snippet: deleteAccount() { const qry: firebase. ...

Unable to utilize Socket.io version 2.0.3

When it comes to developing a video chat app, I decided to utilize socket.io. In order to familiarize myself with this library, I followed various tutorials, but unfortunately, I always encountered the same issue. Every time I attempted to invoke the libr ...

Issue with setTimeout function when used in conjunction with an ajax call

Currently, I am developing a quiz portal where questions are organized in modules. Each module consists of 5 questions: the first 4 are text-based, and the 5th is an image-based question. Upon registering through register.php, users are directed to index. ...

What is the process for incorporating a unique pop-up window in Shopify?

Hey there! I'm looking to incorporate a pop-up window that will appear when a user clicks on a link or button on the product page. This pop-up will display washing instructions, for example. I came across this code snippet, but it doesn't seem t ...

Preserving the video's aspect ratio by limiting the width and height to a maximum of 100%

I am trying to integrate a YouTube video using their embed code in a "pop-up". However, I am facing an issue where the video does not resize to fit within the height of its parent. I want it to be constrained by the div#pop-up that contains the video. Curr ...

Steps for resetting the TypeScript version in VSCode:

I've recently been immersed in a typescript project using Visual Studio Code. Our project relies on an older version of typescript (1.8.10), which has been working seamlessly so far thanks to having the appropriate ts compiler package installed locall ...

Assign tags using a variable within a loop

Consider the scenario where I need to generate a list of li elements: {map(listItems, (obj,i) => <li key={i}> <a target="_blank" href={obj.itemName === 'view_detail' ? `event/${id}` : ''} > <i c ...

When trying to validate an HTML form using AJAX, jQuery, and JavaScript, the validation may not

Here is a high-level overview of what happens: The following code functions correctly... <div id='showme'></div> <div id='theform'> <form ...> <input required ... <input required ... <inpu ...

Ways to categorize items retrieved from an HTTP request to the backend in Angular

When making a call to the backend using this http request: this.StudentEnrollment.getRecordsById(list.value.split(/[\r\n]+/)).subscribe(values => { this.studentObject = values; }); The studentObject is structured as shown below: { recor ...

How can Sequelize handle multiple foreign keys - whether it be for one-to-many relationships or many-to-many relationships

I'm working on a project with two tables: users and alerts. Users should have the ability to upvote and downvote on alerts. Here are the model definitions: Alert module.exports = function(sequelize, DataTypes) { var Alert = sequelize.define("al ...

Trying to automatically select a checkbox upon page load in Angular 6

When the page loads, I want to automatically check a checkbox. Here is my component: var user = ViewprojectComponent.featuresList1; this.rules_id = user[0]; for(let i = 0; i <= this.rules_id.length; i++) { var checkedOn1 = this.rules_id[i]; this.Ru ...