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

95
Views
Construyendo un widget de interruptor de palanca usando reaccionar js

Estoy tratando de construir un widget de alternar. Este es el código que estoy tratando de ejecutar. Aquí, me enfrento a un problema si la palanca está en el estado verdadero, está cambiando correctamente al estado falso. Pero cuando es el estado falso, no se alterna. Soy nuevo en esto de reaccionar js. ¿Alguien podría ayudarme a resolver este problema? Gracias de antemano.

 import { Component, createElement } from "react"; import { CheckboxToggle } from "react-rainbow-components"; export default class SwitchExample extends Component { constructor(props) { super(props); this.handleChange = this.handleChange.bind(this); } handleChange(event) { const { booleanAttribute } = this.props; booleanAttribute.setValue(!event.target.value); } render() { const { booleanAttribute } = this.props; return <CheckboxToggle value={booleanAttribute.value} onClick={this.handleChange} />; } }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

No necesita obtener valor de e.target.value en su lugar, puede usar la devolución de llamada para actualizar el estado como:

demostración de Codesandbox

 handleChange(event) { const { booleanAttribute } = this.props; booleanAttribute.setValue((value) => !value); }
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!