Skip to content

Commit

Permalink
Move instance uuid to useState hook
Browse files Browse the repository at this point in the history
  • Loading branch information
ushamacdonald committed Nov 4, 2020
1 parent f118f85 commit 71ec206
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/components/AccordionItem.tsx
@@ -1,4 +1,5 @@
import * as React from 'react';
import { useState } from 'react';
import DisplayName from '../helpers/DisplayName';
import { DivAttributes } from '../helpers/types';
import { assertValidHtmlId, nextUuid } from '../helpers/uuid';
Expand All @@ -16,12 +17,15 @@ type Props = DivAttributes & {
};

const AccordionItem = ({
uuid = nextUuid(),
uuid: customUuid,
dangerouslySetExpanded,
className = 'accordion__item',
activeClassName,
...rest
}: Props): JSX.Element => {
const [instanceUuid] = useState(nextUuid());
const uuid = customUuid || instanceUuid;

const renderChildren = (itemContext: ItemContext): JSX.Element => {
const { expanded } = itemContext;
const cx = expanded && activeClassName ? activeClassName : className;
Expand Down

0 comments on commit 71ec206

Please sign in to comment.