I am using the from Material UI. Everything works fine but when I add onChange event handler to control the value of the switch the sliding animation does not work anymore.
The switch ref: https://mui.com/material-ui/react-switch/#customization.
I couldn’t figure out how a change handler is preventing an animation. This is just normal sliding animation. I have tried to add transition to its parent element but nothing worked.
I have used @material-ui/core.
2
Answers
Can you show us your code ?
dis you change the props switch ?
In order to control
Switch
state you need bothchecked
andonChange
props.Here is sandbox example of controlled IOS Switch.