clauderic / react-tiny-virtual-list

A tiny but mighty 3kb list virtualization library, with zero dependencies 💪 Supports variable heights/widths, sticky items, scrolling to index, and more!
https://clauderic.github.io/react-tiny-virtual-list/
MIT License
2.46k stars 165 forks source link

Expose container ref to users #63

Closed thisRaptori closed 5 years ago

thisRaptori commented 6 years ago

Hello!

I need to be able to imperatively call ref.scroll({ left: n, behavior: 'smooth' }) on the container of a virtualized list based on users clicking a button - at present there is no way to expose that ref, think the simple approach here should work? Is this something you'd support?

Happy to take a different approach if there's a better way to do this - just let me know and I'd be happy to adjust the PR! 🙂

codecov[bot] commented 6 years ago

Codecov Report

Merging #63 into master will not change coverage. The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master      #63   +/-   ##
=======================================
  Coverage   94.28%   94.28%           
=======================================
  Files           3        3           
  Lines         140      140           
  Branches       17       17           
=======================================
  Hits          132      132           
  Misses          8        8
Impacted Files Coverage Δ
src/index.tsx 100% <ø> (ø) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 5548cc7...11b6244. Read the comment docs.

ghost commented 5 years ago

Not sure if it'd work. With createRef, it causes

Warning: VirtualList: `ref` is not a prop. Trying to access it will result in `undefined`
being returned. If you need to access the same value within the child component,
you should pass it as a different prop.
thisRaptori commented 5 years ago

Weird - it worked for me! Closing this though, we built our own virtualization component which fits our needs. 🙂