Relative Content

Tag Archive for cssreactjssetintervalreact-functional-component

Why is my functional component style not maintained after changing it in an onClick function containing an animation? (React)

I have a functional component called ServiceButton, which is placed in a parent functional component called ServiceScreen.
I defined an on-click function (see below function ChangeText() from ServiceButton), in which I want the currently selected service button to increase its margin-bottom (from -19px to 0px) and the newly-clicked ServiceButton to decrease its margin-bottom (from 0px to -19px), during an animation called with setInterval() and defined within the frame() function. The margins are being changed accordingly, but when calling clearInterval and ending the animations, the ServiceButtons return to their before style.