Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

262
Visualizações
i want to show fake user infomation

i want to show fake user infomation on screen, so i used faker.js. I made fake users infomation, put it in suggestions state, and give the Story component and then i was tying to show user info on screen using map function, but it couldn't be.

this is my code

import faker from "faker";

import { useEffect, useState } from "react";
import Story from "./Story";

const Stories = () => {
  const [suggestions, setSuggestions] = useState([]);

  useEffect(() => {

    const suggestion = [...Array(20)].map((_, i) => ({
      ...faker.helpers.contextualCard(),
      id: i,
    }));
    setSuggestions(suggestion);
  }, []);

  return (
    <div>
      {suggestions.map((profile) => {
        <Story
          key={profile.id}
          img={profile.avatar}
          username={profile.username}
        />;
      })}
      {/* story */}
      {/* story */}
      {/* story */}
      {/* story */}
      {/* story */}
    </div>
  );
};

export default Stories;
import React from "react";

const Story = ({ img, username }) => {
  return (
    <div>
      hihi
      <img src={img} alt="" />
      <p>{username}</p>
    </div>
  );
};

export default Story;

i checked user info at 'suggestion'. it's no problem.

my english is not good, so thanks for read my question.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

As @Emile Bergeron stated in the comments, the .map function isn't returning the Story element as you're expecting.

{suggestions.map((profile) => {
  <Story
    key={profile.id}
    img={profile.avatar}
    username={profile.username}
  />;
})}

Change that to:

{suggestions.map((profile) => {
  return <Story
    key={profile.id}
    img={profile.avatar}
    username={profile.username}
  />;
})}

Or replace the arrow function brackets with parentheses (implicit returns):

{suggestions.map((profile) => (
  <Story
    key={profile.id}
    img={profile.avatar}
    username={profile.username}
  />
))}
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda