【问题标题】:react-dom.production.min.js:189 TypeError: o.map is not a functionreact-dom.production.min.js:189 TypeError: o.map 不是函数
【发布时间】:2023-02-10 08:38:27
【问题描述】:

代码在开发中工作但不在生产中工作。 当我在 Vercel 上上传时,它不起作用。 这是错误->

react-dom.production.min.js:189 TypeError: o.map is not a function
    at gd (Home.jsx:31:15)
    at xo (react-dom.production.min.js:167:137)
    at Cu (react-dom.production.min.js:197:258)
    at Es (react-dom.production.min.js:292:88)
    at bc (react-dom.production.min.js:280:389)
    at gc (react-dom.production.min.js:280:320)
    at mc (react-dom.production.min.js:280:180)
    at ac (react-dom.production.min.js:271:88)
    at ic (react-dom.production.min.js:268:429)
    at w (scheduler.production.min.js:13:203)
du @ react-dom.production.min.js:189

地图功能代码

import React, { useState, useEffect } from "react";
import styled from "styled-components";
import Card from "../components/Card";
import axios from "axios";
const Container = styled.div`
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
`;
const Home = ({ type }) => {
  const [Videos, setVideos] = useState([]);
  useEffect(() => {
    const fetchVideos = async () => {
      // const res = await axios.get(`http://localhost:5000/api/videos/${type}`);
      const res = await axios.get(`/videos/${type}`);
      setVideos(res.data);
      console.log(res.data);
      console.log(typeof res.data);
    };
    fetchVideos();
  }, [type]);

  return (
    <Container>
      {/* {Array.from(videos)
        ? Array.from(videos).map((video) => (
            <Card key={video._id} video={video} />
          ))
        : null} */}
      {/* {Array.from(Videos).map((video) => (
        <Card key={video._id} video={video} />
      ))} */}
      {Videos.map((video) => (
        <Card key={video._id} video={video} />
      ))}
    </Container>
  );
};

export default Home;

我只是想解决这个问题。我无法在主机上部署此代码,因为当我在主机上部署时,在现场部署后会出现错误。

本地主机运行良好,没有错误

【问题讨论】:

    标签: node.js reactjs express mern web-development-server


    【解决方案1】:

    你设法解决了吗?我也有同样的问题

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-08-18
      • 2020-08-25
      • 1970-01-01
      • 2018-05-01
      • 2021-05-01
      • 2017-06-24
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多