Skip to content

Commit 3b2b833

Browse files
committed
Allow changing expanded state of Accordion using prop
1 parent dceaaeb commit 3b2b833

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

packages/core/src/components/AccordionGroup.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,13 @@ const AccordionGroup = ({
4747
const labelColor = expanded ? expandedColor : collapsedColor;
4848
const caretColor = caretColorProp || labelColor;
4949

50+
React.useEffect(() => {
51+
if (expandedProp !== expanded) {
52+
setExpanded(expandedProp);
53+
}
54+
// eslint-disable-next-line react-hooks/exhaustive-deps
55+
}, [expandedProp]);
56+
5057
const handlePressAction = () => {
5158
setExpanded(!expanded);
5259
};

0 commit comments

Comments
 (0)