Skip to content

Commit

Permalink
fix(CollapseGroup): Use stateRef for state management
Browse files Browse the repository at this point in the history
  • Loading branch information
dev-ABsid committed Apr 25, 2024
1 parent a881454 commit 13c7e7b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/components/collapse/collapse-group.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ const CollapseGroupComponent: React.FC<React.PropsWithChildren<CollapseGroupProp
setState([]);
}
} else {
const currentIndexExists = state.includes(currentIndex);
const currentIndexExists = stateRef.current.includes(currentIndex);
if (nextState && !currentIndexExists) {
setState([...state, currentIndex]);
setState([...stateRef.current, currentIndex]);
} else if (!nextState && currentIndexExists) {
setState(state.filter(item => item !== currentIndex));
setState(stateRef.current.filter(item => item !== currentIndex));
}
}
};
Expand Down

0 comments on commit 13c7e7b

Please sign in to comment.