I have the following switch component with change event on my application
const ActivitySwitchChanged = (args) => {
if (accessToken && authorized == "Yes"){
let packageId = args.event.currentTarget.children[0].id;
let checked= 0;
if(args.checked == true){
checked = 2;
}
else if(args.checked == false){
checked = 1;
}
else{
checked = 0;
}
dispatch(updateAction({packageId: packageId, checked: checked, accessToken : accessToken}));
}
}
<SwitchComponent id={workPackage.packageId} change={ActivitySwitchChanged} cssClass='custom-switch'/>
The change event on switch gets triggered on change and performs the action as expected.
However the change that is done is not persisted after the event.
i.e, If I toggle the
Switch On, the change event triggeres with args.checked = true and performs the actions. On finishing that method, the Switch however would remain in Off stage.
This happens vice versa as well.
I need the change/toggle I make to be persisted in the Switch component