Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getScrollParent doesn't work with ref, but works with id #303

Open
magicznyleszek opened this issue Dec 13, 2022 · 1 comment
Open

getScrollParent doesn't work with ref, but works with id #303

magicznyleszek opened this issue Dec 13, 2022 · 1 comment

Comments

@magicznyleszek
Copy link

magicznyleszek commented Dec 13, 2022

Describe the bug
I was trying to use getScrollParent using the method suggested in the documentation. It didn't work. But I think that the problem might be in the typings, not in the code itself. I was not able to do getScrollParent={() => this.scrollParentRef} as TypeScript was not satisfied with passing React ref thing. I tried getScrollParent={() => this.scrollParentRef.current}, but it didn't work. In one of the issues' comment I've found a suggestion to use document.getElementById and it fixed the problem.

To Reproduce
I don't want to spend more time on this, as it already took few hours to debug. I am mostly posting this issue for future archeologists who stumble upon this kinda dead project 🧟 👍

Expected behavior
I would expect this to work as documented 🤷 But the minimum fix for me would be to mention id usage in documentation 😇

Device (please complete the following information):

  • OS: MacOS 13.0.1 (22A400)
  • Browser Firefox 107.0.1 (64-bit)
  • Version "react-infinite-scroller": "^1.2.6"
@CyrusCymmetri
Copy link

For me it worked when I passed it like:
getScrollParent={() => parentRef.current ?? null}

Didn't gave any typescript errors either
const parentRef = useRef<HTMLElement>(null);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants