DEV Community

Discussion on: React Beginner Question Thread ⚛

Collapse
 
olegzhermal profile image
Oleg Zhermal

Hi Dan!
What's the best way, in your opinion, do onScroll animation in react. It looks to me that the most performant way is to get ref to a DOM node and change styles on it directly which is not the 'React way' actually (implementing of course requestAnimationFrame and stuff). Is there a good way to implement it (talking about onscroll parallax effects) through a component state and rerender (React way)?

THNX

Collapse
 
dan_abramov profile image
Dan Abramov

IMO that’s exactly what refs are useful for. Pretty much what I would do, yes.