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

133
Views
How to input array into 1 column table

How to input array into 1 column table ? Audience number 2 have 2 Films B & C. I want to become 1 column. ex [Film B, Film C] in Column Film.

My Table => The Table Image

const AudienceListComponent = () => {
    const [audience, setAudience] = useState([])
    console.log("audience", audience)
    const getAllAudience = () => {
        AudienceService.getAllAudiences().then((response) => {
            console.log('response', response)
            setAudience(response.data)
        })
    }
    useEffect(() => {
        getAllAudience()
    }, [])
    return (
        <div>
            <table className="table table-bordered table-bordered">
                <thead className="table-dark">
                <tr>
                    <th>No</th>
                    <th>Audience Name</th>
                    <th>Film</th>
                </tr>
                </thead>
                <tbody>
                {
                    audience.map((aud, i) => (
                        <tr key={aud.id}>
                            <td>{i + 1}</td>
                            <td>{aud.name}</td>
                            {aud.film.map(films =>
                                <td>{films.title}</td>
                            )}
                        </tr>
                    ))
                }
                </tbody>
            </table>
        </div>
    );
};
export default AudienceListComponent;
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Solved by @Hamza Khan in a comment:

You need to run the map loop inside your td element like this: <td> {aud.film.map(films => films.title )} </td>

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!