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

102
Views
How to hide a react bell icon without creating a separate component?

I am trying to show an icon when i double click an element. Here is my project

https://codesandbox.io/s/brave-herschel-s092nm?file=/src/App.js

I know there is one option to create another component, but I think that is not necessary, because it is just a single icon i want to change, is there another simpler way to change the state ?

updated sandbox link

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

0

Something like this:


import Icon from "/your/Icon/component";

export default function MyApp() {
  const [isIconVisible, setIsIconVisible] = React.useState(false);

  function handleClick(e) {
    if (e.detail === 2) {
      setIsIconVisible(oldState => !oldState);
    }
  }

  return (
    <div>
      <button onClick={handleClick}>Show/hide icon</button>
      {isIconVisible && <Icon />}
    </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!