virtual icon indicating copy to clipboard operation
virtual copied to clipboard

feat(react): compatibility with the React compiler

Open gdorsi opened this issue 1 year ago • 0 comments

Fixes #736 Fixes #743

This PR addresses a critical issue with useVirtualizer compatibility when used alongside the React compiler. Previously, the React compiler would cache results based on the virtualizer instance, preventing updates when virtual items changed.

The solution implements a wrapper using Object.create around the virtualizer instance.

This approach maintains the internal state while allowing the instance reference to change.

The internal state remains constant across updates, with only the instance reference being modified when virtual items change.

This change affects object property behavior. Spread operations and Object.keys() on the virtualizer now return empty results. This impacts code relying on these operations and could be considered a breaking change.

If this, or the getVirtualItems eager evaluation, is a cause of concern we could make the transformation opt-in via option flag or could even be implemented externally as a separate hook.

gdorsi avatar Oct 10 '24 12:10 gdorsi