Skip to content

Commit

Permalink
Merge pull request #405 from jasperfirecai2/main
Browse files Browse the repository at this point in the history
fix(CToast): change special prop `key` to `innerKey`
  • Loading branch information
mrholek authored Sep 18, 2024
2 parents b578251 + 786399c commit 57dcda2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 7 additions & 4 deletions packages/coreui-react/src/components/toast/CToast.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export interface CToastProps extends Omit<HTMLAttributes<HTMLDivElement>, 'title
/**
* @ignore
*/
key?: number
innerKey?: number | string
/**
* Callback fired when the component requests to be closed.
*/
Expand Down Expand Up @@ -76,7 +76,7 @@ export const CToast = forwardRef<HTMLDivElement, CToastProps>(
color,
delay = 5000,
index,
key,
innerKey,
visible = false,
onClose,
onShow,
Expand Down Expand Up @@ -143,7 +143,7 @@ export const CToast = forwardRef<HTMLDivElement, CToastProps>(
onMouseEnter={() => clearTimeout(timeout.current)}
onMouseLeave={() => _autohide()}
{...rest}
key={key}
key={innerKey}
ref={forkedRef}
>
{children}
Expand All @@ -163,7 +163,10 @@ CToast.propTypes = {
color: colorPropType,
delay: PropTypes.number,
index: PropTypes.number,
key: PropTypes.number,
innerKey: PropTypes.oneOfType([
PropTypes.number,
PropTypes.string
]),
onClose: PropTypes.func,
onShow: PropTypes.func,
visible: PropTypes.bool,
Expand Down
2 changes: 1 addition & 1 deletion packages/coreui-react/src/components/toast/CToaster.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export const CToaster = forwardRef<HTMLDivElement, CToasterProps>(
...state,
React.cloneElement(push, {
index: index.current,
key: index.current,
innerKey: index.current,
onClose: (index: number) =>
setToasts((state) => state.filter((i) => i.props.index !== index)),
}),
Expand Down

0 comments on commit 57dcda2

Please sign in to comment.