react-pivottable
react-pivottable copied to clipboard
fix: prevent duplicate item state from React 18 double render
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 thepropUpdater()method for rows and cols keys. - Added unit tests to verify that duplicate entries are not introduced during re-renders.