The program encountered a 'TypeError: education.map is not a function' error when trying to generate the page. All console logs related to this issue will be shown in

Hey everyone, I'm currently working on a project in Next.js with a main file named Project.js. I'm running into some issues trying to export data from the main file to an object called Resume for the education section component...

import EduSection from "@/components/EduSection";
import ExpSection from "@/components/ExpSection";
import IntrestSection from "@/components/IntrestSection";
import Navbar from "@/components/Navbar";
import ProjectSection from "@/components/ProjectSection";
import ResumeHead from "@/components/ResumeHead";
import SkillSection from "@/components/SkillSection";
import React from "react";

function projects() {
  let Resume = {
    Head: {
      firstName: "Abdullah",
      lastName: "Naseer",
      email: "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="7914101817181b1d0c15151811484b4c484b4c391e14181015571a1614">[email protected]</a>",
      phone: "03061356081",
      about: "lorem lipsemmmm ",
    },
    exprience: [
      {
        companyName: "AirLift Express",
        role: "Dispatch Coordinator",
        duration: "March 2022, November 2022",
        jobDes: "leremmmmmmmmm",
        address: "Kohinoor, Faisalabad",
      },
      {
        companyName: "Akount",
        role: "Fr developer",
        duration: "Jan 2011 - Feb 2015",
        jobDes: "did This and that",
        address: "San Monica, CA",
      },
    ],

    education: [
      {
        name: "BSSE",
        address: "Faisalabad",
        duration: "2020-2024",
        schoolName: "GCUF",
      },
      {
        name: "BSSE",
        address: "Faisalabad",
        duration: "2020-2024",
        schoolName: "GCUF",
      },
      {
        name: "BSSE",
        address: "Faisalabad",
        duration: "2020-2024",
        schoolName: "GCUF",
      },
    ],
  };

  return (
    <>
      <Navbar />
      <>
        <link
          href="https://fonts.googleapis.com/css?family=Lato:400,300,700"
          rel="stylesheet"
          type="text/css"
        />
        <div className="container">
          <ResumeHead {...Resume.Head} />
          <div className="details">
            <ExpSection exprience={Resume.exprience} />
            <EduSection education={Resume.education} />
            <ProjectSection />
            <SkillSection />
            <IntrestSection />
          </div>
        </div>
      </>
    </>
  );
}

export default projects;

The problem lies within the EduSection where I am importing the subcomponent as EduItem.

import React from 'react'
import EduItem from './EduItem'

function EduSection(education) {
  return (
    <>
        <div className="section">
        <div className="section__title">Education</div>
        <div className="section__list">
          {education.map((education, index) => (
          <EduItem key={index} {...education} />
        ))}
        </div>
      </div>
    </>
  )
}

export default EduSection;
import React from 'react'

function EduItem(name,address,duration,schoolName) {
  return (
    <>
        <div className="section__list-item">
            <div className="left">
              <div className="name">{name}</div>
              <div className="addr">{address}</div>
              <div className="duration">{duration}</div>
            </div>
            <div className="right">
              <div className="name">{schoolName}</div>
              {/* <div className="desc">did This and that</div> */}
            </div>
          </div>
    </>
  )
}

export default EduItem

Everything is functioning correctly with the experience section but encountering an error specifically in the Education Section.

The error message received is: **Server Error TypeError: education.map is not a function.** Any console logs will show up in the terminal window. Appreciate any assistance provided.

The intended outcome was to pass props data from the main file to EduItem and then to EduSection, unfortunately, it's throwing an error.

Answer №1

You are attempting to utilize the map function on an object that contains all properties. Specifically, your education property is linked to a field within this object. Take a look at the code snippet below:

import React from 'react'
import EduItem from './EduItem'

function EduSection(props) {  
  return (
    <>
      <div className="section">
        <div className="section__title">Education</div>
        <div className="section__list">
          {props.education.map((education, index) => (
            <EduItem key={index} {...education} />
          ))}
        </div>
      </div>
    </>
  )
}

export default EduSection;

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

Embracing the node mindset with a Java foundation

As a Java Developer, I have become accustomed to working in a sequential manner where tasks are executed one after the other or concurrently with multiple threads. The organization of code in a sequential way seemed logical under this paradigm. However, wh ...

Is there a way to turn off predictive text for reCAPTCHA on my mobile device?

Using reCAPTCHA on a sign-up form can get frustrating on mobile devices, with constant dictionary word suggestions while typing. I am aware of how to disable this feature for normal input fields by adding attributes through JavaScript, but shouldn't ...

Storing an image in MongoDB using Multer as a file from Angular is not working as anticipated

I'm currently dealing with an issue that I believe is not functioning correctly. I installed a library in Angular called cropper.js from https://github.com/matheusdavidson/angular-cropperjs. The frontend code provided by the developer utilizes this li ...

Troubleshooting the error during the NexJs deployment on Vercel: "No serverless pages were built"

Whenever I attempt to deploy on Vercel, I encounter this error in my log: Found next.config.js: /** * @type {import('next').NextConfig} */ const nextConfig = { reactStrictMode: true, webpack(config) { config.module.rules.push({ te ...

Updating lists using PHP and Ajax: a dynamic approach

I am currently using a chat service that relies on polling every 20 seconds for new user data in the chat room. I am looking to improve this process by only downloading information for new users who have just joined, rather than re-downloading old data f ...

Alternative to Webpack for modifying global variables in preloaded modules

Is there a way to shim moment.js in webpack similar to how it is done in browserify? I have developed a widget using npm and webpack, which will be included in another application. The other app already has moment.js loaded via a script tag. I want to av ...

Color the faces of Three.js objects using the vertex colors provided

I am working with a mesh and have assigned vertex colors using the following code: var vertColors = MyPolygonProto.polygons[iBorderCounter].polyMesh.geometry.colors; vertColors[vertCount] = new THREE.Color(finalColor.r, finalColor.g, finalColor.b); The p ...

Modifying the default text within a select box using jQuery

Within a select box identified as 'edit-field-service-line-tid', there is default text displayed as '-Any-'. This particular select field has been generated by Drupal. I am looking to use jQuery to change the text '-Any-' to ...

Struggling with transferring information from JavaScript to PHP through the use of Ajax

Currently, I am working on creating a string using a JavaScript function and then passing it to PHP. This is the block of code in my JavaScript file: <script> function passVal(){ var strUrl = buildStringUrl(lat1, lng1, lat2, ...

What is the process for uploading or hosting a Reactjs website?

Currently, I am in the process of developing a React web application project using create-react-app. The project is nearly complete and as part of my preparation, I have been researching how to obtain a hostname. During my research, I came across https://w ...

Arranging elements within an outer array by the contents of their inner arrays

I need help organizing an array based on the alphabetical order of a specific value within the inner arrays. For example: I want to sort this array by the prefix "old," so old A, old B, etc. const array = [ { personName: "Vans", personTags: ["young", " ...

Attempting to retrieve the value from a nested table within a table row using Jquery

<tr role="row" class="odd"> <td style="background-color:white"> <table> <tbody> <tr data-row-id="22"> <td id="pid"><input type="checkbox" class="sub_chk" value="8843" data-id="22">< ...

Only display the parent component in React if there are children components that will be rendered

Navigating this situation in React has me puzzled. Within a group of tabs, I have several chart components that render based on their permission prop. If the user lacks access to a chart, it won't be displayed - straightforward enough. However, I&ap ...

What strategies can I employ to optimize this code in RXJS and Angular?

Is it possible to streamline these nested arrays for more efficient execution after all subscriptions have been completed? I believe there may be a solution involving the use of pipes, mergeMaps, concatMaps, etc. this.teams = [ { Assignments: [{Id: ...

Feeling overwhelmed by JavaScript jQuery errors when making an Ajax request?

I am facing an issue with two buttons on my webpage. One button triggers a table refresh using an ajax php request, while the other button is set to automatically refresh the table every 10 seconds. However, when attempting to access the document, I am enc ...

What is the best way to retrieve the initial cell from a row that the user is currently hovering over?

Is there a way to extract the first cell from a row when a user hovers over it and then clicks a specific key combination? (considering using jQuery) I have a table set up similarly where placing the mouse over a tr and pressing ctrl+c will copy the ID t ...

The AJAX division remains stagnant and does not update unless prompted with an alert due to the error message stating that b

Before anything else, can anyone provide suggestions on how to rewrite my title? Problem: I have a div that is updated through AJAX. Everything works perfectly when all of my error-checking alert calls are included. However, if I remove a specific one, ...

Empty promise will be followed by an array that is empty

How can I fetch time from Firestore using a promise in Angular CLI 8, but the array is empty because the promise has not resolved yet? How can I ensure the array is only called after the getTime() function has finished executing? example.service.ts teste ...

When the page is dynamically loaded, Ng-repeat does not function as expected

I am working on a page that includes the following code snippet: <script> angular.module('myapp', []).controller('categoryCtrl', function($scope) { $scope.category = <? echo json_encode($myarr); ?>; $scope.subcatego ...

What is the best way to retrieve a specific value from a JSON file using a numerical identifier?

Imagine a scenario where there is a JSON file structured like this: { "data": [ { "id": "1", "name": "name1" }, { "id": "2", "name": "name2" } ] } If you know the ...