joshwnj / react-visibility-sensor

Sensor component for React that notifies you when it goes in or out of the window viewport.
MIT License
2.32k stars 195 forks source link

Containment as a RefObject #171

Open ivansky opened 4 years ago

ivansky commented 4 years ago

Hi,

It would be more React-way to use RefObject as approach to get DOM element.

RefObject example

const containmentRef = useRef<HTMLElement>(null); // it will be available after mounting

// it becomes
// { current: null } -> { current: HTMLElement }

<div ref={containmentRef} />
mrtheyann commented 3 years ago

agreed

johnbonds commented 3 years ago

This actually works fine for me now...

containment={messageListSectionRef.current}