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

224
Views
Haga clic en el botón una vez, haga clic en solo renderizar texto

Cómo crear un botón que una vez que haga clic en el botón mostrará solo texto usando el gancho de reacción

 const WelcomeButton = (props) => { const[welcomeBtn, setwelcomeBtn] = useState() const handelClick = () => { if() { retun <p>Hi John</p> } } return ( <div> <button onClick={handelClick}> Welcome </button> </div> ) ; };
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Sugiero usar un estado que rastree que se ha hecho clic en el botón y actualizar/alternar este valor en la devolución de llamada de handleClick . Representar condicionalmente el botón o el texto de bienvenida en función de este estado.

 const WelcomeButton = (props) => { // initial state true to show button const [welcomeBtn, setWelcomeBtn] = React.useState(true); const handelClick = () => { // toggle false to hide button and display welcome message setWelcomeBtn(false); }; return ( <div> {welcomeBtn ? ( <button onClick={handelClick}> Welcome </button> ) : ( <p>Hi John</p> )} </div> ); }; const rootElement = document.getElementById("root"); ReactDOM.render( <WelcomeButton />, rootElement );
 <script src="https://cdnjs.cloudflare.com/ajax/libs/react/17.0.2/umd/react.production.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/17.0.2/umd/react-dom.production.min.js"></script> <div id="root" />

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!