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

POC of react-window to virutalize selectfield options #87

Closed
wants to merge 1 commit into from

Conversation

bdow
Copy link
Contributor

@bdow bdow commented May 27, 2021

No description provided.

))}
<VariableSizeList
itemData={{ items: [...state.collection], state }}
itemSize={() => 42}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can have this figure out the size for us dynamically based on option itself... Whether that is based on the MenuItem type (if we fix those heights), or doing a render of the item to figure out its height.

Copy link
Contributor

Choose a reason for hiding this comment

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

When it figures it out for us, does it just look at the 1st item and assume that is the height of all items in the list?

...I assume that is what it's doing, but AFAICT a core assumption of the virtualized approach is known/consistent height across all items?

itemData={{ items: [...state.collection], state }}
itemSize={() => 42}
height={Math.min(42 * state.collection.size, 400)}
itemCount={state.collection.size}
Copy link
Contributor

@stephenh stephenh May 29, 2021

Choose a reason for hiding this comment

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

Just curious, it seems like with itemCount and itemSize, it could figure out height ... ah sure but you're adding in a min of 400...

item,
state,
style,
}: {
Copy link
Contributor

Choose a reason for hiding this comment

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

Fwiw once the destructure-in-params starts to wrap like this, I think the props: ... and const { ... } = props approach is cleaner.

@stephenh
Copy link
Contributor

Looks great!

@@ -350,27 +360,46 @@ function ListBoxPopup<T extends object>(props: ListBoxPopupProps<T>) {
width: getFieldWidth(compact),
};

const Row = ({ data, index, style }: any) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this needs to be a top-level function, b/c as is the "Row function" will get re-created on each re-render of ListBoxPopup and so look like a brand new component to react. ...I think. Basing this assertion on this ticket that I wandered by:

bvaughn/react-window#302

"Inline item renderers incur a high cost. Because their "type" (the function definition) gets recreated each time the parent component renders, React deeply unmounts and remounts their rendered tree. This means that docs need to teach people not to use them even though they're often more convenient."

@bdow
Copy link
Contributor Author

bdow commented Jun 8, 2021

Closing in favor of using React-Virtuoso instead of React-Window

@bdow bdow closed this Jun 8, 2021
@bdow bdow deleted the selectfield-perf branch November 11, 2021 16:54
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.

2 participants