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

122
Views
Badge implementation with react and material-ui

I am trying to get a badge icon displayed when a component has notes attached to them. I have tried three ways and I get the same results which I find odd. Which one is the best way to implement this? Or is there any other way

first import Badge from '@material-ui/core/Badge';

function NotesBadge({ hasNotes }) {
    
    return (
        <Badge
            anchorOrigin={{
                vertical: 'top',
                horizontal: 'right',}}
            variant="dot"
            color="primary"
            invisible={hasNotes}>
        </Badge>
    );
}

export default NotesBadge;

second

import Badge from '@material-ui/core/Badge';

function NotesBadge({ hasNotes }) {
    
    return (
        <Badge
            anchorOrigin={{
                vertical: 'top',
                horizontal: 'right',}}
            variant="dot"
            color="primary"
            invisible={!hasNotes}>
        </Badge>
    );
}

export default NotesBadge;

third

import Badge from '@material-ui/core/Badge';

function NotesBadge({ hasNotes }) {
    if(hasNotes){
    return (
        <Badge
            anchorOrigin={{
                vertical: 'top',
                horizontal: 'right',}}
            variant="dot"
            color="primary"
            invisible={false}>
        </Badge>
    );
}
}
export default NotesBadge;

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The second approach is the way to go since Badge must be invisible when hasNotes is false, hence the name.

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!