Skip to content

Commit

Permalink
fix(collapse): stop to generate id at each rerender
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeKESTEMAN authored and MartinWeb committed Jan 16, 2024
1 parent 4802f1b commit e6ef73f
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions packages/collapse/src/CollapseCard.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import React from 'react';

import {
Constants,
getComponentClassName,
useId,
useId as getId,
} from '@axa-fr/react-toolkit-core';
import React, { useMemo } from 'react';
import Body, { BodyProps } from './Body';
import Header, { HeaderProps, HeaderToggleElement } from './Header';

Expand Down Expand Up @@ -32,7 +31,7 @@ const CollapseCard = ({
index,
onToggle,
}: CollapseProps) => {
const headerId = useId(id);
const headerId = useMemo(() => getId(id), [id]);
const [open, setOpen] = React.useState(isOpen);

React.useEffect(() => {
Expand Down

0 comments on commit e6ef73f

Please sign in to comment.