react-scroll-to-bottom
react-scroll-to-bottom copied to clipboard
Observer is not a function
When i try to use useObserveScrollPosition hook i got the error messsage: Observer is not a function
I copied one example in the docs and the issue is still there.
To use useObserveScrollPosition hook:
// This is the content rendered inside the scrollable container
const ScrollContent = () => {
const observer = useCallback(({ scrollTop }) => {
console.log(scrollTop);
}, []);
useObserveScrollPosition(observer);
return <div>Hello, World!</div>;
};
If you want to turn off the hook, in the render call, pass a falsy value, e.g. useObserveScrollPosition(false).
Please note that the observer will called very frequently, it is recommended:
- Only observe the scroll position when needed
- Don't put too much logic inside the callback function
- If logic is needed, consider deferring handling using
setTimeoutor similar functions - Make sure the callback function passed on each render call is memoized appropriately, e.g.
useCallback
I receive the same error again and again. Can you give me an example of this?
I receive the same error again and again. Can you give me an example of this?