Skip to content

Commit

Permalink
fix: Memoize 'id' so 'Item's and labels match
Browse files Browse the repository at this point in the history
  • Loading branch information
smockle committed Jun 23, 2021
1 parent 0229d93 commit f38b828
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/ActionList/Item.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {CheckIcon, IconProps} from '@primer/octicons-react'
import React, {useCallback} from 'react'
import React, {useCallback, useMemo} from 'react'
import {get} from '../constants'
import sx, {SxProp} from '../sx'
import Truncate from '../Truncate'
Expand Down Expand Up @@ -307,10 +307,12 @@ export function Item(itemProps: Partial<ItemProps> & {item?: ItemInput}): JSX.El
onKeyPress,
children,
onClick,
id = uniqueId(),
id: _id,
...props
} = itemProps

const id = useMemo(() => _id ?? uniqueId(), [_id])

const keyPressHandler = useCallback(
event => {
if (disabled) {
Expand Down

0 comments on commit f38b828

Please sign in to comment.