Skip to content

Commit 57dcda2

Browse files
authored
Merge pull request #405 from jasperfirecai2/main
fix(CToast): change special prop `key` to `innerKey`
2 parents b578251 + 786399c commit 57dcda2

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

packages/coreui-react/src/components/toast/CToast.tsx

+7-4
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export interface CToastProps extends Omit<HTMLAttributes<HTMLDivElement>, 'title
4444
/**
4545
* @ignore
4646
*/
47-
key?: number
47+
innerKey?: number | string
4848
/**
4949
* Callback fired when the component requests to be closed.
5050
*/
@@ -76,7 +76,7 @@ export const CToast = forwardRef<HTMLDivElement, CToastProps>(
7676
color,
7777
delay = 5000,
7878
index,
79-
key,
79+
innerKey,
8080
visible = false,
8181
onClose,
8282
onShow,
@@ -143,7 +143,7 @@ export const CToast = forwardRef<HTMLDivElement, CToastProps>(
143143
onMouseEnter={() => clearTimeout(timeout.current)}
144144
onMouseLeave={() => _autohide()}
145145
{...rest}
146-
key={key}
146+
key={innerKey}
147147
ref={forkedRef}
148148
>
149149
{children}
@@ -163,7 +163,10 @@ CToast.propTypes = {
163163
color: colorPropType,
164164
delay: PropTypes.number,
165165
index: PropTypes.number,
166-
key: PropTypes.number,
166+
innerKey: PropTypes.oneOfType([
167+
PropTypes.number,
168+
PropTypes.string
169+
]),
167170
onClose: PropTypes.func,
168171
onShow: PropTypes.func,
169172
visible: PropTypes.bool,

packages/coreui-react/src/components/toast/CToaster.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export const CToaster = forwardRef<HTMLDivElement, CToasterProps>(
4545
...state,
4646
React.cloneElement(push, {
4747
index: index.current,
48-
key: index.current,
48+
innerKey: index.current,
4949
onClose: (index: number) =>
5050
setToasts((state) => state.filter((i) => i.props.index !== index)),
5151
}),

0 commit comments

Comments
 (0)