Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
63
rated 0 times [  65] [ 2]  / answers: 1 / hits: 22717  / 7 Years ago, wed, march 15, 2017, 12:00:00

I want to incrementally rotate an image by 45 degrees one time, when the button was clicked, by using reactJs. But I have no clue how to do that. Can anyone give me some tips?


More From » reactjs

 Answers
6

You can keep the current rotation in the state of your component. And add an onClick handler which increments this by 45 at the time. Then use this variable in your render. Here is a quick codepen of how it could be implemented: https://codepen.io/anon/pen/YZrrWM


[#58532] Tuesday, March 14, 2017, 7 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
xavier

Total Points: 711
Total Questions: 91
Total Answers: 121

Location: Gabon
Member since Sat, Jul 25, 2020
4 Years ago
;