Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

257
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda