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

183
Views
Cómo deshabilitar un div después de hacer clic una vez en reaccionar

en ese caso, si hace clic por primera vez en mostrar su show hola mundo, es correcto, pero nuevamente, si hace clic en mostrar, no debería funcionar. ahora se convirtió en un conmutador, pero ¿cómo puedo hacer después de un clic que no funciona? Después de mostrar el hola mundo, no debería volver a ocultarse si desea hacer clic nuevamente. También estoy usando el puntero. El evento tampoco funciona.

 import React, { useState } from "react"; export default function DropDown() { const [show,setShow]=useState(false) return ( <> {show?<h1>hello world</h1>:null} <div onClick={()=>{setShow(!show);return false;}}><span>show</span></div> </> ) }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Simplemente puede modificar su onClick con un valor de tiempo establecido

 onClick={()=>{setShow(true)}} //one time set

código completo

 import React, { useState } from "react"; export default function DropDown() { const [show,setShow]=useState(false) return ( <> {show?<h1>hello world</h1>:null} <div onClick={()=>{setShow(true)}}><span>show</span></div> </> ) }

Si desea deshabilitar ese botón después de show la actualización, puede configurar disabled={show} para ese botón

 import React, { useState } from "react"; export default function DropDown() { const [show,setShow]=useState(false) return ( <> {show?<h1>hello world</h1>:null} <div onClick={()=>{setShow(true)}} disabled={show}><span>show</span></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!