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

191
Views
haga clic en el botón para alternar mostrar un componente y ocultar otro componente en reactjs

Tengo dos botones separados como cuadrícula y botón de lista:

 <button onClick={() => setClassName('jsGridView')} title="Grid View" > <IoGrid className="active" size="25"/> </button> <button onClick={() => setClassName('jsListView')} title="List View" > <BiAlignLeft size="25"/> </button> const [cName, setClassName] = useState('jsGridView');

Entonces, cuando hago clic en el botón Vista de cuadrícula, se mostrará este componente:

 <GridCard className={cName}/>

y cuando hago clic en el botón de vista de lista, se mostrará

 <ListCard className={cName}/>

con este nombre de clase mencionado ..

la clase se cambia pero el componente mostrar ocultar no funciona.

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

0

Puede mostrar diferentes componentes según el valor de cName .

 <div className="row mt-4 book-div"> <div className={cName}> { cName === 'jsGridView' ? <BooksGridCard/> : <BooksListCard/> } </div> </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!