Skip to content

Commit 71ec206

Browse files
committed
Move instance uuid to useState hook
1 parent f118f85 commit 71ec206

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/components/AccordionItem.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import * as React from 'react';
2+
import { useState } from 'react';
23
import DisplayName from '../helpers/DisplayName';
34
import { DivAttributes } from '../helpers/types';
45
import { assertValidHtmlId, nextUuid } from '../helpers/uuid';
@@ -16,12 +17,15 @@ type Props = DivAttributes & {
1617
};
1718

1819
const AccordionItem = ({
19-
uuid = nextUuid(),
20+
uuid: customUuid,
2021
dangerouslySetExpanded,
2122
className = 'accordion__item',
2223
activeClassName,
2324
...rest
2425
}: Props): JSX.Element => {
26+
const [instanceUuid] = useState(nextUuid());
27+
const uuid = customUuid || instanceUuid;
28+
2529
const renderChildren = (itemContext: ItemContext): JSX.Element => {
2630
const { expanded } = itemContext;
2731
const cx = expanded && activeClassName ? activeClassName : className;

0 commit comments

Comments
 (0)