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

356
Views
REACT- How can I put a dash (-) inmy empty cell with my condition?

How can I do to get a dash (-) if I have no animals printed in my table cell. With What I've tried, my cell remains empty if I have animals:[]:

export default function Animals() {
    const data = useMemo(() => [
        {
            Header: 'Animals',
            accessor: (row) => row.animals,
            Cell: (props) => (
                <div>
                    {props.value !== [] ? props.value.map(({ name }) => name).join(", ") : ''}
                    {props.value.length > 0 && <InfoIcon position="right" message={props.value !== [] ? props.value.map((o) => (
                        <span key={o.name}>
                            <b>{o.name}</b>
                            <p>Type: {o.type}</p>
                            <p>Price: {o.price}</p>
                        </span>
                    ))
                        : ''
                    } />}
                </div >
            )
        }
....
}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

use inline ternary condition logic

export default function Animals() {
    const data = useMemo(() => [
        {
            Header: 'Animals',
            accessor: (row) => row.animals,
            Cell: (props) => (
{ props.value !== [] && props.value.length > 0 ?              
<div>
                    {props.value !== [] ? props.value.map(({ name }) => name).join(", ") : ''}
                    {props.value.length > 0 && <InfoIcon position="right" message={props.value !== [] ? props.value.map((o) => (
                        <span key={o.name}>
                            <b>{o.name}</b>
                            <p>Type: {o.type}</p>
                            <p>Price: {o.price}</p>
                        </span>
                    ))
                        : ''
                    } />}
                </div > : <div>-</div> }
            )
        }
....
}
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!