Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

256
Vistas
It is necessary that when you click on "block one", the rest of the blocks are closed, how to release this?

i need that when I click on one block, it opens an input (already implemented), and another block get closed, please help. Here is my code: i've already realized onClick input appearing, but cant handle with other

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">

    <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 Respuestas
Responde la pregunta

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 Denunciar

0

do this

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 Denunciar

0

I've done my problem by myself. Here is my code:

 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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda