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

Unexpected Re-Renders with Inline Render Functions #797

Closed
idanasayag0 opened this issue Nov 27, 2024 · 0 comments
Closed

Unexpected Re-Renders with Inline Render Functions #797

idanasayag0 opened this issue Nov 27, 2024 · 0 comments
Labels

Comments

@idanasayag0
Copy link

Hi,

Referring to issue #420, I noticed that the only way to render a list is by passing a reference to a component, rather than being able to use inline render functions directly.

I tried to create a wrapper component to simplify the API for users. Here's an example:

<WrapperVariableSizeList {...props}>
  {({ index, style }) => (
    <div style={style}>{React.Children.toArray(children)[index]}</div>
  )}
</WrapperVariableSizeList>

With this wrapper, users can pass the children for the list directly, like so:

<WrapperVariableSizeList {...props}>
  {items.map((item) => (
    <p key={item.id}>{item.id}</p>
  ))}
</WrapperVariableSizeList>

However, when using this syntax, I noticed that the list component triggers unexpected re-renders, which affects performance.

Could this behavior be fixed to allow inline render functions without causing unnecessary re-renders?

@github-actions github-actions bot added the Stale label Dec 19, 2024
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Dec 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant