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

93
Visualizações
Building a toggle switch widget using react js

I am trying to build a toggle widget. This is the code I am trying to execute. Here, I am facing one issue if the toggle is in the true state it is toggling to the false state properly. But when it is the false state it is not toggling. I am new to this react js. Could anyone please help me to solve this issue? Thanks in Advance.

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 Respostas
Responde à pergunta

0

You no need to get value from e.target.value instead you can use callback to update state as:

codesandbox demo

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