Skip to content

Commit 37f2879

Browse files
committed
fix: Memoize 'id' so 'Item's and labels match
1 parent ee109b4 commit 37f2879

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/ActionList/Item.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {CheckIcon, IconProps} from '@primer/octicons-react'
2-
import React, {useCallback} from 'react'
2+
import React, {useCallback, useMemo} from 'react'
33
import {get} from '../constants'
44
import sx, {SxProp} from '../sx'
55
import Truncate from '../Truncate'
@@ -307,10 +307,12 @@ export function Item(itemProps: Partial<ItemProps> & {item?: ItemInput}): JSX.El
307307
onKeyPress,
308308
children,
309309
onClick,
310-
id = uniqueId(),
310+
id: _id,
311311
...props
312312
} = itemProps
313313

314+
const id = useMemo(() => _id ?? uniqueId(), [_id])
315+
314316
const keyPressHandler = useCallback(
315317
event => {
316318
if (disabled) {

0 commit comments

Comments
 (0)