Skip to content

Commit 13c7e7b

Browse files
committed
fix(CollapseGroup): Use stateRef for state management
1 parent a881454 commit 13c7e7b

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/components/collapse/collapse-group.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ const CollapseGroupComponent: React.FC<React.PropsWithChildren<CollapseGroupProp
4848
setState([]);
4949
}
5050
} else {
51-
const currentIndexExists = state.includes(currentIndex);
51+
const currentIndexExists = stateRef.current.includes(currentIndex);
5252
if (nextState && !currentIndexExists) {
53-
setState([...state, currentIndex]);
53+
setState([...stateRef.current, currentIndex]);
5454
} else if (!nextState && currentIndexExists) {
55-
setState(state.filter(item => item !== currentIndex));
55+
setState(stateRef.current.filter(item => item !== currentIndex));
5656
}
5757
}
5858
};

0 commit comments

Comments
 (0)