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

docs: add react-virtuoso examples #415

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

docs: add react-virtuoso examples #415

wants to merge 3 commits into from

Conversation

Xhale1
Copy link
Collaborator

@Xhale1 Xhale1 commented Aug 27, 2022

  • Adds examples for react-virtuoso
  • Mark react-virtualized as not maintained

@vercel
Copy link

vercel bot commented Aug 27, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
dnd ✅ Ready (Inspect) Visit Preview Aug 27, 2022 at 7:54AM (UTC)

Copy link
Collaborator

@100terres 100terres left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! Thank you for adding this example 🎉

@@ -186,6 +186,7 @@
"react-dom-16": "npm:[email protected]",
"react-dom-17": "npm:[email protected]",
"react-virtualized": "9.22.3",
"react-virtuoso": "^2.17.2",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the current config off renovate dev-depedencies are pinned 🙂

Suggested change
"react-virtuoso": "^2.17.2",
"react-virtuoso": "2.17.2",

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch (again) 👍

Comment on lines +126 to +128
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
scrollerRef={droppableProvided.innerRef}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should avoid the use of @ts-ignore when we can. Instead of by passing TypeScript we could make sure that we are getting what we are expecting.

In this case, droppableProvided.innerRef is expecting an HTMLElement or null, but scrollerRef can also give the window object. This causes an error, because based on droppableProvided.innerRef's type it can't take the window object as argument. We can make this type error go away if we add a check like we do in this following suggeston:

Suggested change
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
scrollerRef={droppableProvided.innerRef}
scrollerRef={(scroller) => {
invariant(
scroller instanceof HTMLElement || scroller === null,
'scroller should be an instance of HTMLElement or be null',
);
droppableProvided.innerRef(scroller);
}}

Comment on lines +111 to +113
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
scrollerRef={droppableProvided.innerRef}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same 🙂

data={quotes}
style={{ width: 300, height: 500 }}
// eslint-disable-next-line react/no-unstable-nested-components
itemContent={(index, quote) => (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the sake of people not messing up when customizing, I prefer lifting the itemContent callback out as much as possible. If you need to access anything from within the context, you can do this: https://codesandbox.io/s/quiet-butterfly-10xfm5?file=/src/App.tsx

{...props}
className="height-preserving-container"
// check styling in the style tag below
style={{ '--child-height': `${size}px` }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like this hack :(, but for the sake of moving forward, it's ok for now.

@vbgarciag
Copy link

support for nested lists using react virtuoso? 👀 @Xhale1

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

Successfully merging this pull request may close these issues.

4 participants