pmndrs / react-spring

✌️ A spring physics based React animation library
http://www.react-spring.dev/
MIT License
28.11k stars 1.19k forks source link

Can't get property container ref element - React-spring v9. ParallaxLayers. useRef #1770

Closed joshuaellis closed 2 years ago

joshuaellis commented 2 years ago

Feature Request

Theres a small regression in what the refs contained when passed to Parllax components i.e. you don't get to access the actual nodes. It would be helpful to re-introduce these and add this to the documentation. They could be called container as they previously were, but i'm also open to suggestions of a more intuitive name.

Discussed in https://github.com/pmndrs/react-spring/discussions/1769

Originally posted by **pvldsgn** November 24, 2021 Hello everyone! I'm not sure if this belongs to the category of questions, because it looks like a bug: When i want add event scroll to track its position on the page, i used useRef and almost everything worked, except for the smoothness of the scrollToTop event, but that's not about it now. Then I got the value of useRef as an object indicating what kind of object it was and could manipulate it (I needed to get the value of ref.current.container) Was: Снимок экрана 2021-11-24 в 15 53 28 console.log(ref) console.log(ref.current.container) At that time I used react-spring@8.0.27 with that dependency `import { Parallax, ParallaxLayer } from 'react-spring/renderprops-addons'` But when i needed add sticky container it's not worked And I had to turn to the example from the react-spring documentation There I encountered other dependencies `import { Parallax, ParallaxLayer } from '@react-spring/parallax'` With which the sticky container worked, but the opportunity to get the correct ref was broken Become: object itself disappeared and became impersonal Снимок экрана 2021-11-24 в 15 52 54 console.log(ref) console.log(ref.current.container) Question: How do I get the correct ref in this case? Thank's for any help!
kindoflew commented 2 years ago

looking back at 8.0.27 and then 9.x.x on, it seems these were never added to the forwarded refs in the version change (whereas I guess it happened for free in older versions).

i'm into this -- with this addition, users should be able to listen for scroll events on Parallax, which I've seen a few requests for/questions about. I should have some time this week to do it!

joshuaellis commented 2 years ago

That's great news, thanks @kindoflew