Next.js Discord

Discord Forum

production mode => TypeError: e.map is not a function

Unanswered
Turkish Angora posted this in #help-forum
Open in Discord
Turkish AngoraOP
yarn dev fine but
yarn build -> yarn start and got this error
what is this error??

import NormalChatCard from '@/components/ui/ChatCard/NormalChatCard';
import 'keen-slider/keen-slider.min.css';
import { fetchRecommendedChatList } from '@/service/server/community';
import Carousel from './Carousel';

export default async function RecommendChatList() {
  const recommendChatList = await fetchRecommendedChatList();
  return (
    <div>
      <Carousel>
        {recommendChatList.map((list) => (
          <div
            className="max-w-full min-w-full keen-slider__slide"
            key={list.id}
          >
            <NormalChatCard {...list} />
          </div>
        ))}
      </Carousel>
    </div>
  );
}

6 Replies

Cape horse mackerel
probably recommendChatList is undefined | null so you have to check if there is recommendChatList then map through it
{recommendChatList && recommendChatList.map()} // OR
{recommendChatList ? recommendChatList.map() : null}
Turkish AngoraOP
same 😭
Cape horse mackerel
if it's a client component then try to wrap it within useEffect
Turkish AngoraOP
RecommendChatList is server component :fogger:
Cape horse mackerel
can you log recommendChatList ? what is the output of it?
@Cape horse mackerel can you log `recommendChatList` ? what is the output of it?
Turkish AngoraOP
oops i think this error was .env setting issue