Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6287

React .map is not a function when mapping prop array

$
0
0
import React from 'react';import { IProject } from '../interfaces/IProject';export default function Table(projects : IProject[]) {    return (<table className="table-fixed w-full"><thead className="bg-gray-200"><tr><th className="border px-4 py-2 w-12">#</th><th className="border px-4 py-2">Project Name</th><th className="border px-4 py-2">abc</th><th className="border px-4 py-2">xyz</th></tr></thead><tbody>                {projects.map((project) => <tr><td key = {project.id} className="border px-4 py-2">{project.name}</td><td key = {project.id} className="border px-4 py-2">{project.totalHours}</td></tr>                )}  </tbody></table>    );}

I'm getting the runtime error : "TypeError: projects.map is not a function" and I can't figure out what I'm doing wrong.


Viewing all articles
Browse latest Browse all 6287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>