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

fix: revert Grid to async rendering #273

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

Conversation

vursen
Copy link
Contributor

@vursen vursen commented Nov 14, 2024

Description

Wrapping renderers in flushSync doesn't guarantee that the DOM will be updated synchronously. React may still defer it to a micro task if flushSync was called while rendering was already in progress, which is explained in the currently suppressed warning:

Warning: flushSync was called from inside a lifecycle method. React cannot flush when React is already rendering. Consider moving this call to a scheduler task or micro task.

When there are many deferred sync renderers that in turn trigger some async renderers, it can create race conditions that React misinterprets as a possible infinite loop:

Warning: Maximum update depth exceeded. This can happen when a component calls setState inside useEffect, but useEffect either doesn’t have a dependency array, or one of the dependencies changes on every render.

This warning is particularly common in AutoGrid where a mix of sync (GridColumn) and async (Select) renderers is used. This PR reverts Grid to async rendering, which resolves the maximum depth warning and also improves performance. However, GridPro continues to use sync rendering because its web component currently requires the editor to render synchronously.

Fixes #255

Type of change

  • Bugfix

@vursen vursen force-pushed the refactor/revert-grid-to-async-rendering branch from 9ba8bc6 to 0ca7e1c Compare November 15, 2024 14:28
@vursen vursen marked this pull request as ready for review November 15, 2024 14:31
@vursen vursen changed the title refactor: revert Grid to async rendering fix: revert Grid to async rendering Nov 15, 2024
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.

Maximum update depth exceeded with AutoGrid columnRendering set to lazy
1 participant