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

260
Views
Es necesario que al hacer clic en "bloque uno", se cierren el resto de bloques, ¿cómo liberar esto?

necesito que cuando hago clic en un bloque, se abre una entrada (ya implementada) y se cierra otro bloque, por favor ayuda. Aquí está mi código: ya me di cuenta de que aparece la entrada onClick, pero no puedo manejar con otros

 function App() { const [isChecked, setIsChecked] = useState(false) const [isClosed, setIsClosed] = useState(false) const handleCheck = () => { setIsChecked(isChecked => !isChecked) } const handleClose = () => { setIsClosed(isClosed => !isClosed) }

devolver (

 <div className="App"> <div onClick={handleCheck}>block one</div> {isChecked && <input/> } <div onClick={handleClose}>block two</div> {isClosed && <input/> } </div>

); }

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

0

import { useState } from "react" export default function App() { const [isChecked, setIsChecked] = useState(false) const [isClosed, setIsClosed] = useState(false) const handleCheck = () => { setIsChecked(true) setIsClosed(false) } const handleClose = () => { setIsClosed(true) setIsChecked(false) } return( <div className="App"> <div onClick={handleCheck}>block one</div> {isChecked && <input/>} <div onClick={handleClose}>block two</div> {isClosed && <input/>} </div> ) }
about 4 years ago · Juan Pablo Isaza Report

0

hacer esto

 function App() { const [isChecked, setIsChecked] = useState(true) const [isClosed, setIsClosed] = useState(true) const handleCheck = () => { setIsChecked(isChecked => !isChecked) } const handleClose = () => { setIsClosed(isClosed => !isClosed) } return ( <div className="App"> <div onClick={handleClose}>block one</div> {isChecked && <input/> } <div onClick={handleCheck}>block two</div> { isClosed && <input/> } </div> ); }
about 4 years ago · Juan Pablo Isaza Report

0

He hecho mi problema por mí mismo. Aquí está mi código:

 import { useState } from "react" export default function App() { const [isChecked, setIsChecked] = useState(false) const [isClosed, setIsClosed] = useState(false) const handleCheck = () => { setIsChecked(isChecked => !isChecked) } const handleClose = () => { setIsClosed(isClosed => !isClosed) } return( <div className="App"> { isClosed ? null : <div onClick={handleCheck}>block one</div> } {isChecked && <input/>} { isChecked ? null : <div onClick={handleClose}>block two</div> } {isClosed && <input/> } </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!