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

402
Views
How to handle changes in @ionic-react toggle item?

I'm using the @ionic-react library and now I have to add a simple IonToggle true/false value but I'm stuck, I can't handle changes and the funny thing is if I print on screen the new value I see "on" every time. How can I handle events in @ionic-react Toggle?

Code:

    import { IonToggle } from "@ionic/react";
/...
.../    
    <IonItem>
        <IonLabel color="primary" position="stacked">
            Enable Photo
        </IonLabel>
        <IonToggle datatype = "boolean" onChange={(e) => {console.log('test')}}/>
    </IonItem>

Result: enter image description here

I expect true/false value. Do you have any idea? :)

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

0

You can use state to manage the toggle value (true/false)

import React, { useState } from 'react';

const YourContainer: React.FC<ContainerProps> = ({ name }) => {

  // here you set the initial state using the useState hook:
  const [isChecked, setIsChecked] = useState(false);
  
  const buttonToggle = () => {
    setIsChecked(!isChecked);
  }

  return (
    <IonContent>
      <IonList>
       <IonItem>
          <IonLabel color="primary" position="stacked">
            Enable Photo
          </IonLabel>
          <IonToggle checked={isChecked} onChange={(e) => buttonToggle()}/>
        </IonItem>
      </IonList>
    </IonContent>
  )
}
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!