Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

263
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!