Skip to content

fix: prevent duplicate item state from React 18 double render #180

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

YooZiiX
Copy link

@YooZiiX YooZiiX commented Jun 3, 2025

Summary

This pull request addresses a React 18-related issue where moving an item between Columns and Rows in the PivotTableUI causes duplicated state due to React 18's double rendering behavior in Strict Mode.

Changes

  • Introduced a handleDuplicates() utility to filter out duplicate items from state arrays.
  • Integrated handleDuplicates() into the propUpdater() method for rows and cols keys.
  • Added unit tests to verify that duplicate entries are not introduced during re-renders.

YooZiiX added 2 commits June 3, 2025 16:07
…render

- Added guard logic in propUpdater to prevent duplicate items from being pushed to state.
- Improved state initialization to handle React 18's double rendering in Strict Mode.
- Added unit test to ensure duplicate state is not introduced on re-renders.
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.

1 participant